-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (34 loc) · 1.77 KB
/
Dockerfile
File metadata and controls
42 lines (34 loc) · 1.77 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Set the major version of dotnet
ARG DOTNET_VERSION=10.0
# Application to build (Transfers, Lsrp, etc.) - determines which configuration folder to use
ARG APPLICATION=Transfers
# Stage 1 - Build the app using the dotnet SDK
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-azurelinux3.0 AS build
ARG APPLICATION
WORKDIR /build
# Copy the solution file and source code
COPY ./DfE.ExternalApplications.Web.sln ./
COPY ./src/ ./src/
# Mount GitHub Token as a Docker secret, add NuGet source, and build the solution
RUN --mount=type=secret,id=github_token \
--mount=type=cache,target=/root/.nuget/packages \
dotnet restore DfE.ExternalApplications.Web.sln && \
dotnet build DfE.ExternalApplications.Web.sln --no-restore -c Release && \
dotnet publish DfE.ExternalApplications.Web.sln --no-build -o /app
# Copy application-specific configuration to the published output
# The configurations folder is already inside the Web project and gets published
# But we ensure only the specific application's config is in the final image
RUN mkdir -p /app/configurations/${APPLICATION} && \
cp -f ./src/DfE.ExternalApplications.Web/configurations/${APPLICATION}/appsettings*.json /app/configurations/${APPLICATION}/
# Stage 2 - Build a runtime environment
FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION}-azurelinux3.0 AS final
ARG APPLICATION
WORKDIR /app
LABEL org.opencontainers.image.source="https://github.com/DFE-Digital/external-applications-web"
LABEL org.opencontainers.image.description="External Applications - App"
# Set the application name environment variable for runtime configuration loading
ENV APPLICATION_NAME=${APPLICATION}
COPY --from=build /app /app
COPY ./script/web-docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x ./docker-entrypoint.sh
USER $APP_UID