aboutsummaryrefslogtreecommitdiffhomepage
path: root/docker/server/Dockerfile
blob: ffb2c29507255de826f07b2967c61a886fcf1ec8 (plain)
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
# Build stage
FROM node:22-slim AS builder

WORKDIR /app

# Enable corepack for pnpm
RUN corepack enable && corepack prepare pnpm@10.23.0 --activate

# Copy package files
COPY package.json pnpm-lock.yaml ./

# Install all dependencies (including devDependencies for build)
RUN pnpm install --frozen-lockfile

# Copy source files
COPY tsconfig.json esbuild.mjs ./
COPY src/server ./src/server

# Build the server
RUN pnpm build:server

# Production stage
FROM node:22-slim AS production

WORKDIR /app

# Enable corepack for pnpm
RUN corepack enable && corepack prepare pnpm@10.23.0 --activate

# Copy package files
COPY package.json pnpm-lock.yaml ./

# Install production dependencies only
RUN pnpm install --frozen-lockfile --prod

# Copy built server from builder stage
COPY --from=builder /app/dist/server ./dist/server

# Copy drizzle migrations for database setup
COPY drizzle ./drizzle
COPY drizzle.config.ts ./

# Expose the port
EXPOSE 3000

# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000

# Run migrations and start the server
CMD ["sh", "-c", "pnpm db:migrate && node dist/server/index.js"]