generated from tobyscott25/next-auth-drizzle-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
57 lines (42 loc) · 1.13 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
ARG NODE_VERSION=20
# Stage 1 - install deps
# ======================
FROM imbios/bun-node:${NODE_VERSION}-alpine as deps
WORKDIR /app
COPY package.json ./
COPY bun.lockb ./
COPY .env ./
COPY next.config.* ./
COPY tsconfig.json ./
COPY tailwind.config.ts ./
COPY .eslint* ./
COPY postcss.config.js ./
RUN bun install --frozen-lockfile
# Stage 2 - build
# ======================
FROM imbios/bun-node:${NODE_VERSION}-alpine as builder
WORKDIR /app
COPY --from=deps /app/ ./
COPY src ./src
COPY public ./public
RUN npx next-ws-cli@latest patch
RUN bun run build
# Stage 3 - run
# ======================
FROM imbios/bun-node:${NODE_VERSION}-alpine as runner
WORKDIR /app
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder /app/ ./
# Copy Drizzle directory
COPY drizzle ./drizzle
WORKDIR /app
# Set environment variables
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
# Expose the necessary port
EXPOSE 3000
COPY production_run.sh ./
RUN chmod +x /app/production_run.sh
# Run database migrations and then start the server
CMD ./production_run.sh