Files
memer/Dockerfile

51 lines
1.5 KiB
Docker
Raw Normal View History

2026-03-28 01:06:30 -05:00
# ── Stage 1: Build frontend ────────────────────────────────────────────────
FROM node:20-alpine AS frontend-build
WORKDIR /app/frontend
COPY frontend/package*.json ./
2026-03-28 01:09:25 -05:00
RUN npm install
2026-03-28 01:06:30 -05:00
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 ./
2026-03-28 01:09:25 -05:00
RUN npm install
2026-03-28 01:06:30 -05:00
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 ./
2026-03-28 01:09:25 -05:00
RUN npm install --omit=dev
2026-03-28 01:06:30 -05:00
# 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"]