refactor: clone repo from Gitea in Dockerfile instead of COPY

Replace local COPY with git clone --depth 1 so the image can be built
without a local source context. Adds BRANCH build arg (default: main).
This commit is contained in:
2026-02-18 20:12:05 +01:00
parent a3e7f0288e
commit 16848bfdf0
2 changed files with 11 additions and 9 deletions

View File

@@ -540,11 +540,13 @@ docker compose up -d # Start Radicale CalDAV server
### Server Docker Image ### Server Docker Image
```bash ```bash
# Build from repo root: # Build (clones from Gitea, no local context needed):
docker build -f apps/server/docker/Dockerfile -t calchat-server . docker build -f apps/server/docker/Dockerfile -t calchat-server .
# Build from a specific branch:
docker build -f apps/server/docker/Dockerfile --build-arg BRANCH=feature-x -t calchat-server .
docker run -p 3000:3000 --env-file apps/server/.env calchat-server docker run -p 3000:3000 --env-file apps/server/.env calchat-server
``` ```
Multi-stage build: compiles shared + server in build stage, copies only `dist/` and production dependencies to runtime stage. `.dockerignore` excludes `node_modules`, `dist`, `apps/client`, `.git`, `.env`, `*.md`. Multi-stage build: clones the repo from Gitea (`git clone --depth 1`) in the build stage using a `BRANCH` build arg (default: `main`), compiles shared + server, then copies only `dist/` and production dependencies to the runtime stage. No local source context required — the image can be built on any machine with Docker.
### Environment Variables ### Environment Variables
Server requires `.env` file in `apps/server/`: Server requires `.env` file in `apps/server/`:

View File

@@ -1,10 +1,10 @@
FROM node:alpine AS build FROM node:alpine AS build
WORKDIR /app RUN apk add --no-cache git
COPY package.json package-lock.json tsconfig.json ./ ARG BRANCH=main
COPY packages/shared/ packages/shared/ WORKDIR /app
COPY apps/server/ apps/server/ RUN git clone --branch ${BRANCH} --depth 1 https://gitea.gilmour109.de/Gilmour109/calchat.git .
RUN npm ci --workspace=@calchat/server --workspace=@calchat/shared --include-workspace-root RUN npm ci --workspace=@calchat/server --workspace=@calchat/shared --include-workspace-root
@@ -15,9 +15,9 @@ FROM node:alpine
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json ./ COPY --from=build /app/package.json /app/package-lock.json ./
COPY packages/shared/package.json packages/shared/ COPY --from=build /app/packages/shared/package.json packages/shared/
COPY apps/server/package.json apps/server/ COPY --from=build /app/apps/server/package.json apps/server/
RUN npm ci --omit=dev --workspace=@calchat/server --workspace=@calchat/shared --include-workspace-root RUN npm ci --omit=dev --workspace=@calchat/server --workspace=@calchat/shared --include-workspace-root