Skip to content

Commit fb621d4

Browse files
committed
wip
1 parent 1a3032e commit fb621d4

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

apps/api/Dockerfile

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
# Base image with Bun
22
FROM oven/bun:1.2.22 AS base
33

4-
# Install turbo CLI globally using Bun (cache this layer)
4+
# Install turbo CLI globally using Bun
55
FROM base AS turbo-cli
66
RUN bun add -g [email protected]
77

88
# Builder stage
99
FROM turbo-cli AS builder
1010
WORKDIR /app
11-
# Copy all files for turbo prune
11+
# Copy all files
1212
COPY . .
1313
# Use turbo CLI from Bun global install to prune workspaces
1414
RUN turbo prune @midday/api --docker
1515

16-
# Installer stage with build dependencies
16+
# Installer stage
1717
FROM base AS installer
1818
WORKDIR /app
1919

2020
# Install build dependencies for native modules (canvas, etc.)
21-
# This layer is cached unless build dependencies change
2221
RUN apt-get update && apt-get install -y \
2322
python3 \
2423
python3-pip \
@@ -30,39 +29,20 @@ RUN apt-get update && apt-get install -y \
3029
librsvg2-dev \
3130
&& rm -rf /var/lib/apt/lists/*
3231

33-
# Copy only JSON files first (package.json files) for better layer caching
34-
# This allows Docker to cache dependency installation layer separately
32+
# First install the dependencies (as they change less often)
3533
COPY --from=builder /app/out/json/ .
36-
37-
# Install dependencies with Bun cache mount (BuildKit feature)
38-
# Cache this layer - only rebuilds when dependencies change
39-
# Build dependencies (python3, build-essential, node-gyp) are already installed above
34+
# Don't copy the lockfile, allow Bun to generate a fresh one
4035
RUN --mount=type=cache,target=/root/.bun/install/cache \
4136
bun install
4237

43-
# Copy the full source code (this invalidates cache when code changes)
38+
# Copy the full source code
4439
COPY --from=builder /app/out/full/ .
4540

4641
# Copy the prebuilt engine dist from the build context (assumes CI built it)
4742
COPY apps/engine/dist /app/apps/engine/dist
4843

49-
# Runner stage - final runtime image (remove build dependencies)
50-
FROM base AS runner
51-
WORKDIR /app
52-
53-
# Install only runtime libraries needed for canvas (not build tools)
54-
RUN apt-get update && apt-get install -y --no-install-recommends \
55-
libcairo2 \
56-
libpango-1.0-0 \
57-
libjpeg62-turbo \
58-
libgif7 \
59-
librsvg2-2 \
60-
&& rm -rf /var/lib/apt/lists/*
61-
62-
# Copy only runtime files from installer
63-
COPY --from=installer /app/node_modules ./node_modules
64-
COPY --from=installer /app/apps ./apps
65-
COPY --from=installer /app/packages ./packages
44+
# Runner stage (same as installer to avoid another copy)
45+
FROM installer AS runner
6646

6747
# Set the API directory as working directory
6848
WORKDIR /app/apps/api

0 commit comments

Comments
 (0)