forked from ubershmekel/redditp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (29 loc) · 1003 Bytes
/
Dockerfile
File metadata and controls
40 lines (29 loc) · 1003 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
36
37
38
39
40
# RedditP Dockerfile
# Lightweight Node.js image based on Alpine Linux
FROM node:20-alpine
# Add metadata
LABEL maintainer="redditp"
LABEL description="RedditP - Reddit Slideshow Presentation"
LABEL version="1.0.0"
# Set working directory
WORKDIR /app
# Copy package files for dependency installation
COPY package*.json ./
# Install dependencies without excluding devDependencies (since express is there)
RUN npm install && \
npm cache clean --force
# Copy application files
COPY . .
# Create non-root user for security
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs /app
# Switch to non-root user
USER nodejs
# Expose the application port
EXPOSE 8080
# Health check to ensure container is running properly
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:8080', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Start the application
CMD ["npm", "start"]