Skip to content

Instantly share code, notes, and snippets.

@chgeuer
Last active July 1, 2017 13:57
Show Gist options
  • Save chgeuer/84c6430f720ad207079621113475756e to your computer and use it in GitHub Desktop.
Save chgeuer/84c6430f720ad207079621113475756e to your computer and use it in GitHub Desktop.
#
# A .NET Core on CentOS demo application
#
FROM centos:7.3.1611 as centos
RUN yum -y update && \
yum -y install libunwind libicu
#########################
FROM centos as centos_dotnetcore_sdk
WORKDIR /root
ENV SDKURL https://download.microsoft.com/download/E/7/8/E782433E-7737-4E6C-BFBF-290A0A81C3D7/dotnet-dev-centos-x64.1.0.4.tar.gz
ENV SDKTGZ dotnet-dev-centos-x64.1.0.4.tar.gz
# COPY installers/ /root/installers/
RUN mkdir -p /opt/dotnet && \
mkdir /root/installers && curl -SL ${SDKURL} --output /root/installers/${SDKTGZ} && \
tar zxf /root/installers/${SDKTGZ} -C /opt/dotnet && \
ln -s /opt/dotnet/dotnet /usr/local/bin && \
rm -rf /root/installers/ && \
dotnet new --help
#########################
FROM centos_dotnetcore_sdk as builder
WORKDIR /root
ENV APPNAME=myapp
ENV DESIREDVERSION=1.0.5
RUN curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 > /usr/bin/jq && chmod 0755 /usr/bin/jq && \
dotnet new console --name ${APPNAME} && \
cd ${APPNAME} && \
dotnet restore && \
dotnet publish --output publish && \
cd publish && \
cat ${APPNAME}.runtimeconfig.json | jq ".runtimeOptions.framework.version |= \"${DESIREDVERSION}\"" > ${APPNAME}.runtimeconfig.json.updates && \
mv --force ${APPNAME}.runtimeconfig.json.updates ${APPNAME}.runtimeconfig.json
#########################
FROM centos as application
WORKDIR /root
ENV APPNAME=myapp
ENV RUNTIMEURL https://download.microsoft.com/download/2/4/A/24A06858-E8AC-469B-8AE6-D0CEC9BA982A/dotnet-centos-x64.1.0.5.tar.gz
ENV RUNTIMETGZ dotnet-centos-x64.1.0.5.tar.gz
# COPY installers/ /root/installers/
COPY --from=builder /root/${APPNAME}/publish /root/${APPNAME}
RUN mkdir -p /opt/dotnet && \
mkdir /root/installers && curl -SL ${RUNTIMEURL} --output /root/installers/${RUNTIMETGZ} && \
tar zxf /root/installers/${RUNTIMETGZ} -C /opt/dotnet && \
rm -rf /root/installers && \
ln -s /opt/dotnet/dotnet /usr/local/bin
WORKDIR /root/${APPNAME}
# docker run -it --rm --entrypoint=/bin/bash 625ef4cf62c5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment