Add multi-stage Dockerfile (backend + client tarball)
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
**/bin
|
||||||
|
**/obj
|
||||||
|
**/.vs
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.vscode
|
||||||
|
.idea
|
||||||
|
docs
|
||||||
|
tests
|
||||||
|
backend.tests
|
||||||
|
*.md
|
||||||
|
.dockerignore
|
||||||
|
Dockerfile
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
# syntax=docker/dockerfile:1.7
|
||||||
|
|
||||||
|
# ---- Backend build ----
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY Assistant.sln ./
|
||||||
|
COPY backend/backend.csproj backend/
|
||||||
|
COPY backend.tests/backend.tests.csproj backend.tests/
|
||||||
|
RUN dotnet restore backend/backend.csproj
|
||||||
|
COPY backend/ backend/
|
||||||
|
RUN dotnet publish backend/backend.csproj -c Release -o /publish
|
||||||
|
|
||||||
|
# ---- Client bundle ----
|
||||||
|
FROM alpine:3.20 AS bundle
|
||||||
|
WORKDIR /src
|
||||||
|
RUN apk add --no-cache tar gzip
|
||||||
|
COPY client/ client/
|
||||||
|
COPY requirements.txt requirements-nodeps.txt ./
|
||||||
|
RUN tar czf /client.tar.gz client/ requirements.txt requirements-nodeps.txt
|
||||||
|
|
||||||
|
# ---- Final ----
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /publish/ ./
|
||||||
|
RUN mkdir -p ./wwwroot && mkdir -p /data /keys
|
||||||
|
COPY --from=bundle /client.tar.gz ./wwwroot/client.tar.gz
|
||||||
|
|
||||||
|
ENV ASPNETCORE_URLS=http://+:8080
|
||||||
|
ENV ConnectionStrings__Default="Data Source=/data/assistant.db"
|
||||||
|
ENV Install__ClientTarballPath="/app/wwwroot/client.tar.gz"
|
||||||
|
EXPOSE 8080
|
||||||
|
ENTRYPOINT ["dotnet", "backend.dll"]
|
||||||
Reference in New Issue
Block a user