-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (25 loc) · 999 Bytes
/
Copy pathDockerfile
File metadata and controls
35 lines (25 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Build stage - compile React
FROM node:20-alpine AS build-stage
WORKDIR /app
# Copy entire project
COPY . .
# Install dependencies and build client
RUN npm install
RUN npm run build
# Production stage - run server with built client
FROM node:20-alpine
WORKDIR /app
# Copy only what we need from build stage
COPY --from=build-stage /app/server ./server
COPY --from=build-stage /app/client/dist ./client/dist
COPY --from=build-stage /app/package.json ./
# Install only production dependencies
RUN npm install --only=production && \
npm install bcryptjs cors dotenv express express-async-handler express-mongo-sanitize express-rate-limit express-validator helmet jsonwebtoken mongoose morgan
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/api', (r) => {if (r.statusCode !== 404) throw new Error(r.statusCode)})"
# Expose port
EXPOSE 3000
# Start server
CMD ["node", "server/server.js"]