Files
hipctf/Dockerfile
m0rph3us1987 1c756af238 initial commit
2026-01-07 13:27:11 +01:00

44 lines
871 B
Docker

# --- Stage 1: Build Frontend ---
FROM node:20-alpine AS builder
WORKDIR /app
# Copy dependency files
COPY package*.json ./
RUN npm ci
# Copy source code (files in .dockerignore are excluded)
COPY . .
# Build the frontend
RUN npm run build
# --- Stage 2: Production Server ---
FROM node:20-alpine
WORKDIR /app
# Install dependencies for sqlite3
RUN apk add --no-cache python3 make g++
# Copy package files and install production dependencies
COPY package*.json ./
RUN npm ci --omit=dev
# Copy backend server and config
COPY server.js .
COPY metadata.json .
# Copy built frontend from builder stage
COPY --from=builder /app/dist ./dist
# 1. Create the uploads folder explicitly
# 2. Set ownership of the app directory to the 'node' user
RUN mkdir -p uploads && chown -R node:node /app
# Switch to non-root user
USER node
EXPOSE 3000
CMD ["node", "server.js"]