dockerfile for web

This commit is contained in:
2026-01-24 15:28:11 +02:00
parent cb23f37342
commit cbb3fb3421
5 changed files with 82 additions and 1 deletions

15
web/.dockerignore Normal file
View File

@@ -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

51
web/Dockerfile Normal file
View File

@@ -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"]

10
web/compose.yaml Normal file
View File

@@ -0,0 +1,10 @@
services:
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "8667:8667"
environment:
- NODE_ENV=production
restart: unless-stopped

5
web/frontend/Caddyfile Normal file
View File

@@ -0,0 +1,5 @@
:8667 {
root * /usr/share/caddy/dist
file_server
try_files {path} /index.html
}

View File

@@ -26,5 +26,5 @@
"@types/node": "25.0.10",
"typescript": "5.9.3"
},
"packageManager": "pnpm@10.12.4"
"packageManager": "pnpm@10.28.1"
}