-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
27 lines (20 loc) · 1.2 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Set the major version of dotnet
ARG DOTNET_VERSION=8.0
# Stage 1 - Build the app using the dotnet SDK
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"
# Restore, build and publish the dotnet solution
RUN ["dotnet", "restore", "Dfe.Academies.External.Web"]
RUN ["dotnet", "build", "Dfe.Academies.External.Web", "--no-restore", "-c", "Release"]
RUN ["dotnet", "publish", "Dfe.Academies.External.Web", "--no-build", "-o", "/app"]
# Stage 2 - Build a runtime environment
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
RUN ["chmod", "+x", "./docker-entrypoint.sh"]
USER $APP_UID