forked from okupter/kitforstartups
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (33 loc) · 1.11 KB
/
Dockerfile
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
# Build with: docker build -t IMAGE_NAME .
# Run with: docker run -p 3000:3000 --rm --name IMAGE_NAME IMAGE_NAME
FROM node:20-slim AS builder
WORKDIR /staging
# Install necessary build dependencies
RUN apt-get update && apt-get install -y \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Copy package files first for better caching
COPY package.json pnpm-lock.yaml ./
# Enable corepack and install dependencies
RUN corepack enable && \
pnpm install --frozen-lockfile
# Copy the rest of the application
COPY . .
# Generate Drizzle models first, then build
RUN pnpm generate-migrations:postgres && \
pnpm generate-migrations:mysql && \
pnpm build && \
pnpm prune --prod
FROM node:20-slim
ARG ORIGIN=http://localhost:3000
ENV ORIGIN=$ORIGIN
WORKDIR /app
# Copy necessary files from builder
COPY --from=builder /staging/package.json /staging/pnpm-lock.yaml ./
COPY --from=builder /staging/node_modules ./node_modules
COPY --from=builder /staging/build ./build
COPY --from=builder /staging/.tunnel_key ./.tunnel_key
EXPOSE 3000
CMD ["node", "-r", "dotenv/config", "./build/index.js"]