-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (39 loc) · 1.31 KB
/
Dockerfile
File metadata and controls
55 lines (39 loc) · 1.31 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
48
49
50
51
52
53
54
55
# Use Node.js 18 Alpine for smaller image size
FROM node:18-alpine
# Install curl for health checks
RUN apk add --no-cache curl
# Set working directory
WORKDIR /app
# Copy package files for the entire project
COPY package*.json ./
# Install root-level dependencies
RUN npm ci
# Copy backend package files
COPY backend/package*.json ./backend/
# Install backend dependencies
WORKDIR /app/backend
RUN npm ci
# Install Prisma CLI globally to ensure it's available
RUN npm install -g prisma
# Copy backend source code
COPY backend/ ./
# Generate Prisma client with dummy DATABASE_URL for build
ENV DATABASE_URL="postgresql://dummy:dummy@localhost:5432/dummy"
RUN prisma generate --generator client
# Install ts-node for production runtime
RUN npm install -g ts-node tsconfig-paths
# Remove the dummy DATABASE_URL
ENV DATABASE_URL=""
# Create non-root user for security
RUN addgroup -g 1001 -S nodejs
RUN adduser -S backend -u 1001
# Change ownership to the nodejs user
RUN chown -R backend:nodejs /app
USER backend
# Expose port (Render automatically assigns PORT env var)
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${PORT:-5000}/health || exit 1
# Start the application with ts-node
CMD ["ts-node", "-r", "tsconfig-paths/register", "server.ts"]