-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (61 loc) · 2.54 KB
/
Dockerfile
File metadata and controls
69 lines (61 loc) · 2.54 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
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
USER app
WORKDIR /app
EXPOSE 80 443
# Copy the default certificate
COPY ["Lighthouse.Backend/Lighthouse.Backend/certs/LighthouseCert.pfx", "/app/certs/LighthouseCert.pfx"]
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG BUILD_CONFIGURATION=Release
ARG VERSION=0.0.1
WORKDIR /src
COPY ["Lighthouse.Backend/", "."]
WORKDIR "/src"
RUN dotnet restore "./Lighthouse.sln" -a "$TARGETARCH"
RUN dotnet build "Lighthouse.Backend/Lighthouse.Backend.csproj" -c "$BUILD_CONFIGURATION" -o /app/build/
RUN dotnet build "Lighthouse.Migrations.Postgres/Lighthouse.Migrations.Postgres.csproj" \
-c "$BUILD_CONFIGURATION" \
-o /app/build/
RUN dotnet build "Lighthouse.Migrations.Sqlite/Lighthouse.Migrations.Sqlite.csproj" \
-c "$BUILD_CONFIGURATION" \
-o /app/build/
FROM --platform=$BUILDPLATFORM node:24-bookworm-slim AS node-builder
WORKDIR /node
COPY Lighthouse.Frontend /node
RUN corepack enable \
&& corepack prepare pnpm@10.12.1 --activate \
&& pnpm install --frozen-lockfile --ignore-scripts \
&& pnpm run build-docker
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN mkdir -p ./Lighthouse.Backend/wwwroot
COPY --from=node-builder /node/dist/. ./Lighthouse.Backend/wwwroot/
RUN dotnet publish "./Lighthouse.Backend/Lighthouse.Backend.csproj" \
-c "$BUILD_CONFIGURATION" \
-o /app/publish \
/p:UseAppHost=false \
/p:PublishSingleFile=false \
/p:Version="$VERSION" \
--no-self-contained \
/p:EnablePublishBeforeCleanup=true
FROM base AS final
WORKDIR /app
# Install the latest PostgreSQL client tools from the PGDG apt repository.
# pg_dump is backwards compatible, so the latest client works with any supported server version.
USER root
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl gnupg \
&& curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
| gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg \
&& echo "deb [signed-by=/etc/apt/trusted.gpg.d/postgresql.gpg] https://apt.postgresql.org/pub/repos/apt \
$(. /etc/os-release && echo "$VERSION_CODENAME")-pgdg main" \
> /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends postgresql-client \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /app/logs /app/data && chown -R app:app /app/logs /app/data
USER app
COPY --from=publish /app/publish .
ENV Kestrel__Endpoints__Http__Url="http://+:80"
ENV Kestrel__Endpoints__Https__Url="https://+:443"
ENV LIGHTHOUSE_DOCKER="true"
ENTRYPOINT ["dotnet", "Lighthouse.dll"]