-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (36 loc) · 1.11 KB
/
Dockerfile
File metadata and controls
52 lines (36 loc) · 1.11 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
# Build stage
FROM node:20 AS builder
# Install pnpm and esbuild
RUN corepack enable && corepack prepare pnpm@latest --activate && \
npm install -g esbuild
# Set working directory
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy source code and public directory
COPY . .
# Build the application
RUN esbuild src/index.ts --outfile=dist/index.cjs --bundle --platform=node --format=cjs --banner:js='#!/usr/bin/env node' && \
chmod +x dist/index.cjs
# Production stage
FROM node:20-alpine
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Set working directory
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install production dependencies only
RUN pnpm install --prod --frozen-lockfile
# Copy built files from builder stage
COPY --from=builder /app/dist ./dist
# Copy public directory
COPY --from=builder /app/public ./public
# Copy index.html
COPY src/index.html ./dist
# Set environment variables
ENV NODE_ENV=production
# Start the application
CMD ["node", "dist/index.cjs" ]