-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dev
More file actions
42 lines (30 loc) · 1 KB
/
Dockerfile.dev
File metadata and controls
42 lines (30 loc) · 1 KB
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
36
37
38
39
40
41
42
# ================================
# Development Dockerfile with Hot Reload
# ================================
FROM node:20-alpine
# Set development environment
ENV NODE_ENV=development
# Install dumb-init for signal handling
RUN apk add --no-cache dumb-init
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001
# Set working directory
WORKDIR /app
# Copy package files
COPY --chown=nodejs:nodejs package*.json ./
# Install ALL dependencies (including devDependencies for development)
RUN npm ci --no-audit --no-fund
# Copy application source
COPY --chown=nodejs:nodejs . .
# Switch to non-root user
USER nodejs
# Expose port
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
CMD node -e "require('http').get('http://localhost:5000/health', (r) => {if (r.statusCode !== 200) throw new Error('Health check failed')})"
# Use dumb-init
ENTRYPOINT ["dumb-init", "--"]
# Start with nodemon for hot reload
CMD ["npm", "run", "dev"]