Last active
December 14, 2023 17:40
-
-
Save JesseObrien/05b948daec9036da04b7baa9e18e2cf7 to your computer and use it in GitHub Desktop.
Dockerfile for asp dotnet core with timezone change, npm install, and two-stage build process. This uses the 'aspnetcore-build' container to produce the build with ALL of the SDK dependencies, and the 'aspnetcore' container to run the code itself, cutting down the production container's size.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM microsoft/aspnetcore-build:2.0 AS build-env | |
WORKDIR /app | |
# Copy csproj and restore as distinct layers | |
COPY *.csproj ./ | |
RUN dotnet restore | |
# Copy everything else and build | |
COPY . ./ | |
RUN rm -rf node_modules && npm install | |
RUN dotnet publish -c Release -o out | |
# Build runtime image | |
FROM microsoft/aspnetcore:2.0 | |
# Change timezone to local time | |
ENV TZ=America/Toronto | |
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | |
WORKDIR /app | |
COPY --from=build-env /app/out . | |
ENTRYPOINT ["dotnet", "MyApp.dll"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment