build 1
This commit is contained in:
50
Dockerfile
Normal file
50
Dockerfile
Normal file
@@ -0,0 +1,50 @@
|
||||
# ── Stage 1: Build frontend ────────────────────────────────────────────────
|
||||
FROM node:20-alpine AS frontend-build
|
||||
WORKDIR /app/frontend
|
||||
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY frontend/ ./
|
||||
RUN npm run build
|
||||
# Output lands in /app/backend/public via vite outDir
|
||||
|
||||
# ── Stage 2: Build backend ─────────────────────────────────────────────────
|
||||
FROM node:20-alpine AS backend-build
|
||||
WORKDIR /app/backend
|
||||
|
||||
COPY backend/package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY backend/ ./
|
||||
# Copy the built frontend into backend/public before TS compile (static refs)
|
||||
COPY --from=frontend-build /app/backend/public ./public
|
||||
RUN npm run build
|
||||
|
||||
# ── Stage 3: Runtime ───────────────────────────────────────────────────────
|
||||
FROM node:20-alpine AS runtime
|
||||
WORKDIR /app
|
||||
|
||||
# Install production deps only
|
||||
COPY backend/package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
# Copy compiled backend
|
||||
COPY --from=backend-build /app/backend/dist ./dist
|
||||
|
||||
# Copy frontend assets
|
||||
COPY --from=backend-build /app/backend/public ./public
|
||||
|
||||
# Data volumes
|
||||
VOLUME ["/data/images", "/data/db"]
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
ENV DATA_DIR=/data
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s \
|
||||
CMD wget -qO- http://localhost:3000/api/tags || exit 1
|
||||
|
||||
CMD ["node", "dist/index.js"]
|
||||
Reference in New Issue
Block a user