-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.buildtest
More file actions
77 lines (56 loc) · 2.09 KB
/
Dockerfile.buildtest
File metadata and controls
77 lines (56 loc) · 2.09 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
70
71
72
73
74
75
76
77
# Dockerfile for building and running the application
# --- Stage 1: Base dependencies (Closer to original Dockerfile) ---
FROM oven/bun:1 AS base
WORKDIR /app
# Copy entire project context (respecting .dockerignore)
COPY . .
# Install ALL workspace dependencies (needed for linking)
# Use --frozen-lockfile for reproducible installs
RUN bun install --frozen-lockfile --ignore-scripts
# --- Stage 2: Builder ---
FROM base AS builder
WORKDIR /app
# Source code is already copied in the 'base' stage
# Build the common package
RUN cd common && bun run clean && bun run build
# Build the API package
RUN cd api && bun run build
# Build the UI package
RUN cd ui && bun run build
# --- Stage 3: API Runtime ---
FROM oven/bun:1-slim AS runtime-api
WORKDIR /app
# Copy production dependencies and built code from builder stage
COPY --from=builder /app/bun.lock /app/package.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/common ./common
COPY --from=builder /app/api ./api
# Set working directory to API
WORKDIR /app/api
# Hono typically listens on 8000 inside the container
EXPOSE 8000
# Command to run the built API server
# Assumes api/package.json has a "start:prod" script like "node dist/index.js"
# Or directly run the built file
CMD ["node", "dist/index.js"]
# --- Stage 4: UI Runtime ---
# Use a slim bun image which includes Node.js
FROM oven/bun:1-slim AS runtime-ui
WORKDIR /app
ENV NUXT_HOST=0.0.0.0
ENV NUXT_PORT=3000
# Copy built UI artifacts from builder stage
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/ui/package.json ./ui/package.json
# Copy the installed node_modules from the builder stage
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/common ./common
# Copy the built Next.js application
COPY --from=builder /app/ui/.next ./ui/.next/
COPY --from=builder /app/bun.lock ./bun.lock
# Set working directory to the UI folder where package.json and .next reside
WORKDIR /app/ui
# Expose the port Next.js will run on
EXPOSE 3000
# Command to run the built Next.js production server
CMD ["next", "start"]