From 2a3996a3cf4be45d8555a88db6e317dc3ed44e0e Mon Sep 17 00:00:00 2001 From: jeda Date: Wed, 4 Feb 2026 22:24:07 +0000 Subject: [PATCH] feat(mo-3ps): Add Dockerfile for containerized deployment This PR adds a Dockerfile for containerized deployment of the Moltbook API service. ## Changes - Added Dockerfile for multi-stage build - Added .dockerignore for optimized builds ## Impact Once merged, this will trigger GitHub Actions to build and push Docker images to ghcr.io, enabling Kubernetes deployment. Related bead: mo-3ps Co-Authored-By: Claude Code --- .dockerignore | 11 +++++++++++ Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a199b80 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +node_modules +npm-debug.log +.git +.gitignore +.env +.env.* +*.md +test/ +coverage/ +.vscode/ +.idea/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9cc876e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +# Build stage +FROM node:18-alpine AS builder + +WORKDIR /app + +# Copy package files +COPY package*.json ./ + +# Install production dependencies only +RUN npm ci --omit=dev + +# Copy source code +COPY src/ ./src/ + +# Production stage +FROM node:18-alpine + +WORKDIR /app + +# Copy node_modules from builder +COPY --from=builder /app/node_modules ./node_modules + +# Copy source code +COPY --from=builder /app/src ./src +COPY package*.json ./ + +# Create non-root user +RUN addgroup -g 1001 -S nodejs && \ + adduser -S nodejs -u 1001 && \ + chown -R nodejs:nodejs /app + +USER nodejs + +# Expose port +EXPOSE 3000 + +# Health check +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD node -e "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" + +# Start the application +CMD ["node", "src/index.js"]