-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.PersonsApi
28 lines (22 loc) · 1.07 KB
/
Dockerfile.PersonsApi
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
28
# Set the major version of dotnet
ARG DOTNET_VERSION=8.0
# Build the app using the dotnet SDK
FROM "mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-azurelinux3.0" AS build
WORKDIR /build
ARG CI
ENV CI=${CI}
COPY . .
COPY ./script/personsapi.docker-entrypoint.sh /app/docker-entrypoint.sh
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", "PersonsApi"]
RUN dotnet build PersonsApi --no-restore -c Release -p CI=${CI}
RUN ["dotnet", "publish", "PersonsApi", "--no-build", "-o", "/app"]
# 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/academies-api"
LABEL org.opencontainers.image.description="Persons API"
COPY --from=build /app /app
RUN ["chmod", "+x", "./docker-entrypoint.sh"]
USER $APP_UID