-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reduces the overall final image size by using Azure Linux * Offers maximum compatibility with Azure infrastructure * Uses arbitrary user instead of 'root'
- Loading branch information
1 parent
e22cbe0
commit 864d9bd
Showing
1 changed file
with
20 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
# Stage 1 | ||
ARG ASPNET_IMAGE_TAG=8.0-bookworm-slim | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
WORKDIR /build | ||
# Set the major version of dotnet | ||
ARG DOTNET_VERSION=8.0 | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
# Stage 1 - Build the app using the dotnet SDK | ||
ARG DOTNET_VERSION | ||
FROM "mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-azurelinux3.0" AS build | ||
WORKDIR /build | ||
|
||
COPY ./Dfe.Academies.External.Web/ ./Dfe.Academies.External.Web/ | ||
COPY ./script/web-docker-entrypoint.sh /app/docker-entrypoint.sh | ||
|
||
# Mount GitHub Token as a Docker secret so that NuGet Feed can be accessed | ||
RUN --mount=type=secret,id=github_token dotnet nuget add source --username USERNAME --password $(cat /run/secrets/github_token) --store-password-in-clear-text --name github "https://nuget.pkg.github.com/DFE-Digital/index.json" | ||
RUN dotnet restore Dfe.Academies.External.Web | ||
RUN dotnet build Dfe.Academies.External.Web --no-restore | ||
RUN dotnet publish Dfe.Academies.External.Web -c Release -o /app --no-restore | ||
|
||
COPY ./script/web-docker-entrypoint.sh /app/docker-entrypoint.sh | ||
# Restore, build and publish the dotnet solution | ||
RUN ["dotnet", "restore", "Dfe.Academies.External.Web"] | ||
RUN ["dotnet", "build", "Dfe.Academies.External.Web", "--no-restore"] | ||
RUN ["dotnet", "publish", "Dfe.Academies.External.Web", "--no-build", "-c", "Release", "-o", "/app"] | ||
|
||
# Stage 2 | ||
ARG ASPNET_IMAGE_TAG | ||
FROM "mcr.microsoft.com/dotnet/aspnet:${ASPNET_IMAGE_TAG}" AS final | ||
LABEL org.opencontainers.image.source=https://github.com/DFE-Digital/Dfe.Academies.External | ||
# Stage 2 - Build a runtime environment | ||
ARG DOTNET_VERSION | ||
FROM "mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION}-azurelinux3.0" AS final | ||
WORKDIR /app | ||
LABEL org.opencontainers.image.source="https://github.com/DFE-Digital/Dfe.Academies.External" | ||
|
||
COPY --from=build /app /app | ||
WORKDIR /app | ||
RUN chmod +x ./docker-entrypoint.sh | ||
RUN ["chmod", "+x", "./docker-entrypoint.sh"] | ||
|
||
USER $APP_UID | ||
ENV ASPNETCORE_HTTP_PORTS=80 | ||
EXPOSE 80/tcp |