- Add Express.js backend with REST API - Implement comprehensive security measures (helmet, rate limiting, input validation) - Add Docker volume support for persistent JSON storage - Update container security (non-root user, minimal Alpine) - Add deployment and security documentation - Configure production-ready Docker setup with Coolify compatibility 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
47 lines
1.1 KiB
Docker
47 lines
1.1 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
ARG NODE_VERSION=20.15.0
|
|
FROM node:${NODE_VERSION}-alpine AS build
|
|
WORKDIR /app
|
|
|
|
# Install all deps for build
|
|
COPY package*.json ./
|
|
RUN npm ci && npm cache clean --force
|
|
|
|
# Build frontend
|
|
COPY . .
|
|
ENV NODE_ENV=production
|
|
ENV NODE_OPTIONS=--max-old-space-size=512
|
|
RUN npm run build
|
|
|
|
# ---- Runtime (Node.js server with static files) ----
|
|
FROM node:${NODE_VERSION}-alpine AS runtime
|
|
WORKDIR /app
|
|
|
|
# Install curl for healthcheck
|
|
RUN apk add --no-cache curl
|
|
|
|
# Copy package.json and production dependencies
|
|
COPY package*.json ./
|
|
RUN npm ci --only=production && npm cache clean --force
|
|
|
|
# Copy server files and built frontend
|
|
COPY server ./server
|
|
COPY --from=build /app/dist ./dist
|
|
|
|
# Create data directory for volume mount
|
|
RUN mkdir -p /app/data && chown -R node:node /app/data
|
|
|
|
# Set data directory environment variable
|
|
ENV DATA_DIR=/app/data
|
|
ENV NODE_ENV=production
|
|
ENV PORT=80
|
|
|
|
# Switch to non-root user
|
|
USER node
|
|
|
|
EXPOSE 80
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD curl -fsS http://localhost/api/health >/dev/null || exit 1
|
|
|
|
CMD ["npm", "start"]
|