-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
108 lines (85 loc) · 3.1 KB
/
Dockerfile
File metadata and controls
108 lines (85 loc) · 3.1 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
ARG DOTNET_VERSION=10.0
# ============================================================
# Stage 1 - Build + Install Playwright (Ubuntu SDK)
# ============================================================
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-noble AS build
WORKDIR /build
ARG CI
ENV CI=${CI}
# Install Playwright CLI
RUN dotnet tool install --global Microsoft.Playwright.CLI
ENV PATH="${PATH}:/root/.dotnet/tools"
# Copy solution
COPY ./src/ ./src/
COPY Directory.Build.props ./
COPY DfE.ExternalApplications.Api.sln ./
# Restore + build
RUN dotnet restore DfE.ExternalApplications.Api.sln
RUN dotnet build ./src/DfE.ExternalApplications.Api -c Release --no-restore
# Install Playwright browsers + OS dependencies (Ubuntu!)
RUN playwright install --with-deps
# Publish final output
RUN dotnet publish ./src/DfE.ExternalApplications.Api -c Release --no-build -o /app
# ============================================================
# Stage 2 - EF Migration Builder
# ============================================================
FROM build AS efbuilder
WORKDIR /build
ENV PATH=$PATH:/root/.dotnet/tools
ENV DOTNET_ROOT=/usr/share/dotnet
RUN dotnet tool install --global dotnet-ef --version 10.*
RUN mkdir /sql
RUN dotnet ef migrations bundle -r linux-x64 \
--configuration Release \
--project ./src/DfE.ExternalApplications.Api \
--output /sql/migratedb \
--no-build \
--self-contained
# ============================================================
# Stage 3 - Init Container (Keeps Azure Linux if needed)
# ============================================================
FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION}-azurelinux3.0 AS initcontainer
WORKDIR /sql
COPY --from=efbuilder /sql /sql
COPY --from=build /app/appsettings* /sql/
COPY --from=build /app/appsettings* /DfE.ExternalApplications.Api/
# ============================================================
# Stage 4 - Final Runtime (Ubuntu) + Playwright Runtime Support
# ============================================================
FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION}-noble AS final
WORKDIR /app
# Install Playwright required system dependencies
RUN apt-get update && \
apt-get install -y \
libnss3 \
libatk1.0-0t64 \
libatk-bridge2.0-0t64 \
libcups2t64 \
libdbus-1-3 \
libdrm2 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
libgbm1 \
libasound2t64 \
libxshmfence1 \
libxkbcommon0 \
libxext6 \
libxfixes3 \
libx11-6 \
libx11-xcb1 \
libglib2.0-0t64 \
libgl1 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Copy app + Playwright browsers
COPY --from=build /app /app
COPY --from=build /root/.cache/ms-playwright /home/app/.cache/ms-playwright
RUN chmod -R 755 /home/app/.cache/ms-playwright
COPY script/api-docker-entrypoint.sh /app/docker-entrypoint.sh
RUN sed -i 's/\r$//' /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh
ENV ASPNETCORE_URLS=http://+:8080
USER $APP_UID
ENTRYPOINT ["/app/docker-entrypoint.sh"]