forked from crackedstudio/tikka
-
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 KB
/
Copy pathDockerfile
File metadata and controls
47 lines (33 loc) · 1 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
# Stage 1: Build
FROM node:22-alpine AS builder
# Check for pnpm-lock.yaml and use it
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Copy package management files
COPY package.json pnpm-lock.yaml ./
# Install dependencies (frozen-lockfile for consistency)
RUN pnpm install --frozen-lockfile
# Copy source code and build
COPY . .
RUN pnpm run build
# Stage 2: Production
FROM node:22-alpine AS runner
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Copy only production dependencies
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --prod --frozen-lockfile
# Copy built application from builder stage
COPY --from=builder /app/dist ./dist
# Environment variables
ENV NODE_ENV=production
ENV PORT=3001
# Expose the application port
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --no-check-certificate http://localhost:3001/health -O /dev/null || exit 1
# Command to run the application
CMD ["node", "dist/main.js"]