-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.render
More file actions
62 lines (43 loc) · 1.46 KB
/
Dockerfile.render
File metadata and controls
62 lines (43 loc) · 1.46 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
56
57
58
59
60
61
62
# Multi-stage Dockerfile optimized for Render deployment
FROM node:18-alpine AS base
# Install system dependencies
RUN apk add --no-cache openssl ca-certificates
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY tsconfig.json ./
# Install all dependencies (including dev for build)
RUN npm install
# Copy source code
COPY . .
# Generate Prisma client
RUN npx prisma generate
# Build the application
RUN npm run build
# Production stage
FROM node:18-alpine AS production
# Install system dependencies
RUN apk add --no-cache openssl ca-certificates
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install only production dependencies
RUN npm install --omit=dev && npm cache clean --force
# Copy built application from base stage
COPY --from=base /app/dist ./dist
COPY --from=base /app/prisma ./prisma
COPY --from=base /app/node_modules/.prisma ./node_modules/.prisma
# Create non-root user
RUN addgroup -g 1001 -S nodejs && adduser -S openera -u 1001
# Create logs directory and set permissions
RUN mkdir -p logs && chown -R openera:nodejs /app
USER openera
# Expose port (Render uses PORT environment variable)
EXPOSE $PORT
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD node -e "require('http').get(\`http://localhost:\${process.env.PORT || 10000}/ping\`, (res) => { \
process.exit(res.statusCode === 200 ? 0 : 1) \
}).on('error', () => process.exit(1))"
# Start the application
CMD ["npm", "start"]