build 2
This commit is contained in:
58
Dockerfile
Normal file
58
Dockerfile
Normal file
@@ -0,0 +1,58 @@
|
||||
# ── Stage 1: Build frontend ───────────────────────────────────────────────────
|
||||
FROM node:20-slim AS frontend-builder
|
||||
|
||||
WORKDIR /build/frontend
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm ci
|
||||
COPY frontend/ ./
|
||||
RUN npm run build
|
||||
|
||||
# ── Stage 2: Build backend ────────────────────────────────────────────────────
|
||||
FROM node:20-slim AS backend-builder
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
python3 make g++ \
|
||||
--no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /build/backend
|
||||
COPY backend/package*.json backend/tsconfig.json ./
|
||||
RUN npm ci
|
||||
COPY backend/src ./src
|
||||
RUN npm run build && npm prune --production
|
||||
|
||||
# ── Stage 3: Runtime ─────────────────────────────────────────────────────────
|
||||
FROM node:20-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
nginx \
|
||||
chromium \
|
||||
fonts-freefont-ttf \
|
||||
supervisor \
|
||||
--no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3001
|
||||
ENV DATABASE_PATH=/app/data/tracker.db
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Backend
|
||||
COPY --from=backend-builder /build/backend/dist ./backend/dist
|
||||
COPY --from=backend-builder /build/backend/node_modules ./backend/node_modules
|
||||
COPY backend/package.json ./backend/
|
||||
|
||||
# Frontend → nginx web root
|
||||
COPY --from=frontend-builder /build/frontend/dist /usr/share/nginx/html
|
||||
|
||||
# Config files
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
|
||||
# Persistent data volume
|
||||
VOLUME ["/app/data"]
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
||||
Reference in New Issue
Block a user