-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (33 loc) · 1.43 KB
/
Dockerfile
File metadata and controls
47 lines (33 loc) · 1.43 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
43
44
45
46
47
# Use Node.js 18 as the base image
FROM node:18-alpine
# Set working directory
WORKDIR /app
# Copy package.json and install dependencies
COPY package.json* ./
RUN npm install --only=production
# Copy the main server file explicitly
COPY websocket-server.js ./
# Copy the rest of the application files
COPY . .
# Verify critical files exist (for debugging)
RUN ls -la /app/ && echo "Checking for websocket-server.js:" && ls -la /app/websocket-server.js
# Create necessary directories for data persistence
RUN mkdir -p /app/archive /app/logs /app/tribe-data/bug /app/tribe-data/bear /app/tribe-data/sloth /app/tribe-data/wolf /app/tribe-data/vashon /app/tribe-data/mib /app/tribe-data/flounder
# Expose the port the app runs on
EXPOSE 8000
# Set environment variables
ENV PORT=8000
ENV NODE_ENV=production
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:8000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })" || exit 1
RUN ls -la /app/ && echo "Checking for websocket-server.js:" && ls -la /app/websocket-server.js
# Create a non-root user for security
RUN addgroup -g 1001 -S tribesuser && \
adduser -S tribesuser -u 1001
# Change ownership of the app directory to the non-root user
RUN chown -R tribesuser:tribesuser /app
# Switch to non-root user
USER tribesuser
# Command to run the application
CMD ["node", "websocket-server.js"]