Add Docker support and update README
- Add Dockerfile with multi-stage build for Node.js + React - Add docker-compose.yml for easy local deployment - Add .dockerignore to exclude unnecessary files - Add GitHub Actions workflow for automatic Docker image builds and pushes to GHCR - Add comprehensive DOCKER.md documentation - Update README with Docker installation instructions
This commit is contained in:
1 parent
564aa7c1b8
commit
4e4f2fb324
6 files changed
+382
-17
No files matched your search
+52
@@ -0,0 +1,52 @@
|
||||
# Build stage for React client
|
||||
FROM node:20-alpine AS client-builder
|
||||
|
||||
WORKDIR /app/client
|
||||
|
||||
# Copy client package files
|
||||
COPY client/package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy client source
|
||||
COPY client/src ./src
|
||||
COPY client/public ./public
|
||||
|
||||
# Build React app
|
||||
RUN npm run build
|
||||
|
||||
# Final stage - Node.js server
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dumb-init for proper signal handling
|
||||
RUN apk add --no-cache dumb-init
|
||||
|
||||
# Copy server package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install production dependencies only
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy server code
|
||||
COPY server ./server
|
||||
|
||||
# Copy built React client from builder stage
|
||||
COPY --from=client-builder /app/client/build ./client/build
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S nodejs -u 1001
|
||||
|
||||
USER nodejs
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3001
|
||||
|
||||
# Use dumb-init to handle signals properly
|
||||
ENTRYPOINT ["dumb-init", "--"]
|
||||
|
||||
# Start the server
|
||||
CMD ["node", "server/index.js"]
|
||||
Reference in new issue
Block a user