implement docker

This commit is contained in:
tistopandita
2026-06-11 15:28:54 +07:00
parent b350e4e2c8
commit 448fcb54f0
6 changed files with 161 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
# ─── Stage 1: Install dependencies ──────────────────────────────────────────
FROM node:22-alpine AS deps
WORKDIR /app
COPY backend/package*.json ./
RUN npm ci --omit=dev
# ─── Stage 2: Runtime ────────────────────────────────────────────────────────
FROM node:22-alpine AS runner
WORKDIR /app
# Install dumb-init untuk proper signal handling
RUN apk add --no-cache dumb-init
# Copy dependencies dari stage deps
COPY --from=deps /app/node_modules ./node_modules
# Copy backend source
COPY backend/ ./backend/
# Copy frontend static files
COPY frontend/ ./frontend/
# Set working directory ke backend (karena server.js ada di sini)
WORKDIR /app/backend
# Non-root user untuk keamanan
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser
EXPOSE 3000
ENV NODE_ENV=production
ENV PORT=3000
# Health check (dipakai Coolify untuk monitoring)
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD wget -qO- http://localhost:3000/health || exit 1
ENTRYPOINT ["dumb-init", "--"]
CMD ["node", "server.js"]