52 lines
1023 B
Docker
52 lines
1023 B
Docker
# Multi-stage Dockerfile for flog
|
|
# Build: deps -> build -> runtime
|
|
|
|
# Stage 1: Dependencies
|
|
FROM node:20-slim AS deps
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json package-lock.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Stage 2: Build
|
|
FROM node:20-slim AS build
|
|
WORKDIR /app
|
|
|
|
# Copy dependencies
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Set environment for CRA build (avoid treating warnings as errors)
|
|
ENV CI=false
|
|
|
|
# Build client and server
|
|
RUN npm run build
|
|
|
|
# Prune dev dependencies
|
|
RUN npm prune --omit=dev
|
|
|
|
# Stage 3: Runtime
|
|
FROM node:20-slim AS runtime
|
|
WORKDIR /app
|
|
|
|
# Copy built assets and runtime files
|
|
COPY --from=build /app/dist ./dist
|
|
COPY --from=build /app/build ./build
|
|
COPY --from=build /app/package.json ./package.json
|
|
COPY --from=build /app/node_modules ./node_modules
|
|
COPY config.json ./config.json
|
|
COPY index.js ./index.js
|
|
COPY index.ts ./index.ts
|
|
|
|
# Create data directory
|
|
RUN mkdir -p /app/data
|
|
|
|
# Expose port
|
|
EXPOSE 3010
|
|
|
|
# Run the server
|
|
CMD ["node", "dist/index.js"]
|