-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (38 loc) · 1.3 KB
/
Dockerfile
File metadata and controls
57 lines (38 loc) · 1.3 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
# Multi-stage build: first build frontend, then run backend with frontend
# Stage 1: Build frontend
FROM oven/bun:latest AS frontend-builder
ARG PUBLIC_API_URL
ARG PUBLIC_WS_URL
# Convert ARG to ENV so SvelteKit can access them during build
ENV PUBLIC_API_URL=${PUBLIC_API_URL}
ENV PUBLIC_WS_URL=${PUBLIC_WS_URL}
WORKDIR /app/front
# Copy package files first for better layer caching
COPY front/package.json front/bun.lock ./
# Install dependencies first (better caching)
RUN bun install --frozen-lockfile
# Copy frontend source (excluding node_modules via .dockerignore or explicit copy)
COPY front/ ./
COPY domain/ ../domain/
# Build frontend (outputs to ../back/public from front directory)
RUN bun run build
# Stage 2: Run backend with frontend
FROM oven/bun:latest
WORKDIR /app
# Copy backend package files
COPY back/package.json back/bun.lockb ./back/
WORKDIR /app/back
# Install backend dependencies
RUN bun install --frozen-lockfile
# Copy backend source
COPY back/src/ ./src/
COPY back/tsconfig.json ./tsconfig.json
COPY back/bunfig.toml ./bunfig.toml
# Copy domain (needed for backend)
COPY domain/ ../domain/
# Copy built frontend from builder stage
COPY --from=frontend-builder /app/back/public ./public
# Expose the port
EXPOSE 3000
# Run migrations and start server
CMD ["bun", "run", "compose"]