-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (33 loc) · 1.43 KB
/
Dockerfile
File metadata and controls
44 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
# Use Node.js LTS version
FROM node:20-slim
# Set working directory
WORKDIR /app
# No native build deps needed (pg driver; DB is Supabase/Postgres via DATABASE_URL)
# Copy package files
COPY package.json package-lock.json* ./
# Install dependencies
RUN npm ci --only=production
# Copy application files
COPY . .
# Copy .env.example as .env template (users should mount their own .env)
RUN cp .env.example .env 2>/dev/null || true
# Create non-root user for security
# Check if UID 1000 exists, if so rename the user, otherwise create new user
RUN if id -u 1000 >/dev/null 2>&1; then \
EXISTING_USER=$(id -un 1000); \
if [ "$EXISTING_USER" != "appuser" ]; then \
usermod -l appuser $EXISTING_USER && \
groupmod -n appuser $(id -gn 1000); \
fi; \
else \
useradd -m -u 1000 appuser; \
fi && \
chown -R 1000:1000 /app
USER appuser
# Expose port (default is 3005, can be overridden with PORT env var)
EXPOSE 3005
# Health check - checks /health endpoint
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD node -e "const http = require('http'); const port = process.env.PORT || 3005; http.get(`http://localhost:${port}/health`, (r) => {let data=''; r.on('data', d=>data+=d); r.on('end', ()=>{process.exit(r.statusCode===200?0:1)});}).on('error', ()=>{process.exit(1)});"
# Start the application
CMD ["npm", "start"]