-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (54 loc) · 2.07 KB
/
Copy pathDockerfile
File metadata and controls
69 lines (54 loc) · 2.07 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# ==========================================
# GLOBAL ARGS (Change versions here)
# ==========================================
ARG NODE_VERSION=24.12.0
ARG BUN_VERSION=1.3.2
ARG CADDY_VERSION=latest
# ==========================================
# Stage 1: Get Bun Binary
# ==========================================
FROM oven/bun:${BUN_VERSION}-slim AS bun-image
# ==========================================
# Stage 2: Get Caddy with DuckDNS
# ==========================================
FROM serfriz/caddy-duckdns:${CADDY_VERSION} AS caddy-image
# ==========================================
# Stage 3: Build Next.js App
# ==========================================
FROM node:${NODE_VERSION}-slim AS next-builder
# Install Python and Build Tools for C++ modules (like utp-native)
RUN apt-get update && \
apt-get install -y python3 make g++ build-essential && \
rm -rf /var/lib/apt/lists/*
# Install Bun by copying it from Stage 1
COPY --from=bun-image /usr/local/bin/bun /usr/local/bin/bun
WORKDIR /app
COPY package.json bun.lock ./
# Install dependencies using Bun
RUN bun install --frozen-lockfile
COPY . .
# Build the app (You can use 'bun run build' or 'npm run build')
RUN bun run build
# ==========================================
# Stage 4: Final Production Image
# ==========================================
FROM node:${NODE_VERSION}-slim AS runner
# Install Supervisor
RUN apt-get update && apt-get install -y supervisor && rm -rf /var/lib/apt/lists/*
COPY supervisord.conf /etc/supervisord.conf.template
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Copy Caddy Binary
COPY --from=caddy-image /usr/bin/caddy /usr/bin/caddy
COPY Caddyfile /etc/caddy/Caddyfile
ENV XDG_DATA_HOME=/caddy/data
ENV XDG_CONFIG_HOME=/caddy/config
WORKDIR /app
# Copy Next.js Artifacts
COPY --from=next-builder /app/package.json ./package.json
COPY --from=next-builder /app/node_modules ./node_modules
COPY --from=next-builder /app/.next ./.next
COPY --from=next-builder /app/dist ./dist
# Expose and Run
EXPOSE 3000 443
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]