feat(infra): add production Dockerfile and docker-compose.prod.yml
Multi-stage alpine-based build, healthcheck on /api/health, /data volume. Verified end-to-end: image builds, container starts, health returns 200. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
node_modules
|
||||||
|
.svelte-kit
|
||||||
|
build
|
||||||
|
data
|
||||||
|
.git
|
||||||
|
docs
|
||||||
|
tests
|
||||||
|
*.log
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
39
Dockerfile
Normal file
39
Dockerfile
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# syntax=docker/dockerfile:1.7
|
||||||
|
|
||||||
|
FROM node:22-alpine AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Alpine needs build tools for better-sqlite3 native module
|
||||||
|
RUN apk add --no-cache python3 make g++ libc6-compat
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Remove dev dependencies for the runtime image
|
||||||
|
RUN npm prune --omit=dev
|
||||||
|
|
||||||
|
FROM node:22-alpine AS runner
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
|
||||||
|
COPY --from=builder /app/build ./build
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
COPY --from=builder /app/package.json ./package.json
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
ENV PORT=3000
|
||||||
|
ENV DATABASE_PATH=/data/kochwas.db
|
||||||
|
ENV IMAGE_DIR=/data/images
|
||||||
|
|
||||||
|
VOLUME ["/data"]
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
||||||
|
CMD wget -qO- http://localhost:3000/api/health > /dev/null || exit 1
|
||||||
|
|
||||||
|
CMD ["node", "build/index.js"]
|
||||||
25
docker-compose.prod.yml
Normal file
25
docker-compose.prod.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
services:
|
||||||
|
kochwas:
|
||||||
|
build: .
|
||||||
|
image: kochwas:latest
|
||||||
|
ports:
|
||||||
|
- '3000:3000'
|
||||||
|
volumes:
|
||||||
|
- ./data:/data
|
||||||
|
environment:
|
||||||
|
- DATABASE_PATH=/data/kochwas.db
|
||||||
|
- IMAGE_DIR=/data/images
|
||||||
|
- SEARXNG_URL=http://searxng:8080
|
||||||
|
- NODE_ENV=production
|
||||||
|
depends_on:
|
||||||
|
- searxng
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
searxng:
|
||||||
|
image: searxng/searxng:latest
|
||||||
|
volumes:
|
||||||
|
- ./searxng:/etc/searxng
|
||||||
|
environment:
|
||||||
|
- BASE_URL=http://searxng:8080/
|
||||||
|
- INSTANCE_NAME=kochwas-search
|
||||||
|
restart: unless-stopped
|
||||||
Reference in New Issue
Block a user