-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (44 loc) · 1.72 KB
/
Dockerfile
File metadata and controls
60 lines (44 loc) · 1.72 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
# Build stage - use slim (Debian) instead of alpine for glibc compatibility
FROM node:18-slim AS builder
WORKDIR /app
# Install OpenSSL for Prisma
RUN apt-get update && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*
# Copy package files
COPY package*.json ./
COPY prisma ./prisma/
# Install ALL dependencies (including devDependencies needed for build)
RUN npm ci && \
npx prisma generate
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Remove devDependencies for production
RUN npm prune --omit=dev
# Production stage - use slim (Debian) for glibc compatibility with onnxruntime
FROM node:18-slim
WORKDIR /app
# Install dumb-init and OpenSSL (required by Prisma)
RUN apt-get update && apt-get install -y --no-install-recommends \
dumb-init \
openssl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -g 1001 nodejs && \
useradd -u 1001 -g nodejs nodejs
# Copy built application from builder
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nodejs:nodejs /app/prisma ./prisma
COPY --from=builder --chown=nodejs:nodejs /app/package*.json ./
# Switch to non-root user
USER nodejs
# Default port (Railway overrides via PORT env var)
ENV PORT=3001
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "const port = process.env.PORT || 3001; require('http').get('http://localhost:' + port + '/api/v1/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1); });"
# Run migrations then start app
ENTRYPOINT ["dumb-init", "--"]
CMD ["sh", "-c", "npx prisma migrate deploy && node dist/server.js"]