From cbb3fb342149d08c6f5d6bbd867f36a20b37a84e Mon Sep 17 00:00:00 2001 From: k4rli Date: Sat, 24 Jan 2026 15:28:11 +0200 Subject: [PATCH] dockerfile for web --- web/.dockerignore | 15 +++++++++++++ web/Dockerfile | 51 ++++++++++++++++++++++++++++++++++++++++++ web/compose.yaml | 10 +++++++++ web/frontend/Caddyfile | 5 +++++ web/package.json | 2 +- 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 web/.dockerignore create mode 100644 web/Dockerfile create mode 100644 web/compose.yaml create mode 100644 web/frontend/Caddyfile diff --git a/web/.dockerignore b/web/.dockerignore new file mode 100644 index 0000000..f9afc76 --- /dev/null +++ b/web/.dockerignore @@ -0,0 +1,15 @@ +node_modules +npm-debug.log +pnpm-debug.log +.DS_Store + +# Turbo cache +.turbo + +# IDE specific files +biome.json + +# Build output +dist +build +out diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 0000000..2f09d36 --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,51 @@ +# Use a multi-stage build to optimize the final image size + +# Stage 1: Prepare the pruned workspace +FROM node:24-alpine AS prepare + +WORKDIR /app + +RUN npm install -g pnpm@10.28.1 +RUN npm install -g turbo@2.7.5 + +COPY . . + +# Prune the workspace to only include what's needed for the web service +RUN pnpm turbo prune biostacker-frontend --docker + +# Stage 2: Build the application +FROM node:24-alpine AS builder + +WORKDIR /app + +RUN npm install -g pnpm@10.28.1 +RUN npm install -g turbo@2.7.5 + +# First install the dependencies (as they change less often) +COPY --from=prepare /app/out/json/ . +RUN pnpm install --frozen-lockfile + +# Build the project +COPY --from=prepare /app/out/full/ . + +RUN pwd +RUN ls -la /app +COPY --from=prepare /app/tsconfig.base.json . + +RUN pnpm build +RUN ls -la /app + +# Stage 3: Create the production image with Caddy as reverse proxy +FROM caddy:2-alpine AS runner + +WORKDIR /usr/share/caddy + +# Copy the built assets from the builder stage +COPY --from=builder /app/frontend/dist ./dist + +# Copy Caddyfile for configuration +COPY --from=builder /app/frontend/Caddyfile ./Caddyfile + +EXPOSE 8667 + +CMD ["caddy", "run", "--config", "/usr/share/caddy/Caddyfile", "--adapter", "caddyfile"] diff --git a/web/compose.yaml b/web/compose.yaml new file mode 100644 index 0000000..e7d3034 --- /dev/null +++ b/web/compose.yaml @@ -0,0 +1,10 @@ +services: + web: + build: + context: . + dockerfile: Dockerfile + ports: + - "8667:8667" + environment: + - NODE_ENV=production + restart: unless-stopped diff --git a/web/frontend/Caddyfile b/web/frontend/Caddyfile new file mode 100644 index 0000000..41234b0 --- /dev/null +++ b/web/frontend/Caddyfile @@ -0,0 +1,5 @@ +:8667 { + root * /usr/share/caddy/dist + file_server + try_files {path} /index.html +} diff --git a/web/package.json b/web/package.json index 442747e..f9a0b4f 100644 --- a/web/package.json +++ b/web/package.json @@ -26,5 +26,5 @@ "@types/node": "25.0.10", "typescript": "5.9.3" }, - "packageManager": "pnpm@10.12.4" + "packageManager": "pnpm@10.28.1" }