1- FROM ubuntu:26.04
1+ FROM ubuntu:26.04 AS controller-base
22
3- ARG DOCKER_GIT_CONTROLLER_REV=unknown
43ARG UBUNTU_APT_MIRROR=
5- LABEL io.prover-coder-ai.docker-git.controller-rev=$DOCKER_GIT_CONTROLLER_REV
64
75ENV DEBIAN_FRONTEND=noninteractive
8- ENV DOCKER_GIT_CONTROLLER_REV=$DOCKER_GIT_CONTROLLER_REV
96ENV BUN_INSTALL=/opt/bun
107ENV PATH=/opt/bun/bin:$PATH
118WORKDIR /workspace
@@ -55,16 +52,23 @@ RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
5552 && npm i -g node-gyp \
5653 && rm -rf /var/lib/apt/lists/*
5754
55+ FROM controller-base AS workspace-deps
56+
5857COPY package.json bun.lock bunfig.toml tsconfig.base.json tsconfig.json ./
59- COPY patches ./patches
60- COPY scripts ./scripts
61- COPY packages ./packages
62- COPY .gitmodules ./.gitmodules
63- COPY third_party ./third_party
58+ RUN mkdir -p packages/api packages/app packages/docker-git-session-sync packages/lib
59+ COPY packages/api/package.json ./packages/api/package.json
60+ COPY packages/app/package.json ./packages/app/package.json
61+ COPY packages/docker-git-session-sync/package.json ./packages/docker-git-session-sync/package.json
62+ COPY packages/lib/package.json ./packages/lib/package.json
6463
6564RUN set -eu; \
6665 for attempt in 1 2 3 4 5; do \
67- if bun install --frozen-lockfile --silent; then \
66+ if bun install \
67+ --frozen-lockfile \
68+ --silent \
69+ --filter @effect-template/api \
70+ --filter @effect-template/lib \
71+ --filter @prover-coder-ai/docker-git-session-sync; then \
6872 exit 0; \
6973 fi; \
7074 echo "bun install attempt ${attempt} failed; retrying..." >&2; \
@@ -73,28 +77,78 @@ RUN set -eu; \
7377 done; \
7478 echo "bun install failed after retries" >&2; \
7579 exit 1
80+
81+ FROM workspace-deps AS workspace-static
82+
83+ COPY patches ./patches
84+ COPY scripts ./scripts
85+ COPY packages/docker-git-session-sync ./packages/docker-git-session-sync
86+ COPY packages/lib ./packages/lib
87+
88+ RUN bun run --cwd packages/docker-git-session-sync build
7689RUN bun run --cwd packages/lib build
77- RUN bun run --cwd packages/api build
78- RUN bun scripts/skiller-apply-docker-git-patches.mjs
79- RUN test -f third_party/skiller-desktop-skills-manager/package.json \
80- && cd third_party/skiller-desktop-skills-manager \
81- && for attempt in 1 2 3 4 5; do \
82- if bun install --frozen-lockfile --silent; then \
83- break; \
84- fi; \
85- if [ "$attempt" = "5" ]; then \
86- echo "skiller bun install failed after retries" >&2; \
87- exit 1; \
88- fi; \
89- echo "skiller bun install attempt ${attempt} failed; retrying..." >&2; \
90- rm -rf /root/.bun/install/cache node_modules; \
91- sleep $((attempt * 2)); \
92- done \
93- && bun run build \
94- && touch out/.docker-git-browser-folder-picker.patch \
95- && mkdir -p out/preload \
96- && ln -sf index.mjs out/preload/index.js
9790
91+ FROM controller-base AS skiller-build
92+
93+ ARG DOCKER_GIT_CONTROLLER_BUILD_SKILLER=1
94+
95+ COPY patches ./patches
96+ COPY scripts/skiller-apply-docker-git-patches.mjs ./scripts/skiller-apply-docker-git-patches.mjs
97+ COPY .gitmodules ./.gitmodules
98+ COPY third_party ./third_party
99+
100+ RUN if [ "$DOCKER_GIT_CONTROLLER_BUILD_SKILLER" = "1" ]; then \
101+ bun scripts/skiller-apply-docker-git-patches.mjs; \
102+ else \
103+ echo "Skipping Skiller build for controller image." ; \
104+ fi
105+ RUN if [ "$DOCKER_GIT_CONTROLLER_BUILD_SKILLER" = "1" ]; then \
106+ test -f third_party/skiller-desktop-skills-manager/package.json \
107+ && cd third_party/skiller-desktop-skills-manager \
108+ && for attempt in 1 2 3 4 5; do \
109+ if bun install --frozen-lockfile --silent; then \
110+ break; \
111+ fi; \
112+ if [ "$attempt" = "5" ]; then \
113+ echo "skiller bun install failed after retries" >&2; \
114+ exit 1; \
115+ fi; \
116+ echo "skiller bun install attempt ${attempt} failed; retrying..." >&2; \
117+ rm -rf /root/.bun/install/cache node_modules; \
118+ sleep $((attempt * 2)); \
119+ done \
120+ && bun run build \
121+ && touch out/.docker-git-browser-folder-picker.patch \
122+ && mkdir -p out/preload \
123+ && ln -sf index.mjs out/preload/index.js; \
124+ else \
125+ cd third_party/skiller-desktop-skills-manager \
126+ && mkdir -p node_modules/electron/dist out/main out/renderer out/preload \
127+ && printf '%s\n ' '#!/usr/bin/env sh' 'echo "Skiller is not bundled in this controller image." >&2' 'exit 1' \
128+ > node_modules/electron/dist/electron \
129+ && chmod +x node_modules/electron/dist/electron \
130+ && printf '%s\n ' 'throw new Error("Skiller is not bundled in this controller image.")' > out/main/index.js \
131+ && printf '%s\n ' '<!doctype html><title>Skiller unavailable</title>' > out/renderer/index.html \
132+ && printf '%s\n ' 'export {}' > out/preload/index.mjs \
133+ && touch out/.docker-git-browser-folder-picker.patch \
134+ && ln -sf index.mjs out/preload/index.js; \
135+ fi
136+
137+ FROM workspace-static AS controller-final
138+
139+ COPY .gitmodules ./.gitmodules
140+ COPY --from=skiller-build /workspace/third_party/skiller-desktop-skills-manager ./third_party/skiller-desktop-skills-manager
141+ COPY packages/api ./packages/api
142+
143+ RUN ./packages/api/node_modules/.bin/tsc -p packages/api/tsconfig.json
144+
145+ ARG DOCKER_GIT_CONTROLLER_REV=unknown
146+ ARG DOCKER_GIT_CONTROLLER_BUILD_SKILLER=1
147+ LABEL io.prover-coder-ai.docker-git.controller-rev=$DOCKER_GIT_CONTROLLER_REV
148+ LABEL io.prover-coder-ai.docker-git.controller-build-skiller=$DOCKER_GIT_CONTROLLER_BUILD_SKILLER
149+
150+ ENV DOCKER_GIT_CONTROLLER_REV=$DOCKER_GIT_CONTROLLER_REV
151+ ENV DOCKER_GIT_CONTROLLER_BUILD_SKILLER=$DOCKER_GIT_CONTROLLER_BUILD_SKILLER
98152ENV DOCKER_GIT_API_PORT=3334
99153ENV DOCKER_GIT_DOCKER_RUNTIME=isolated
100154ENV DOCKER_HOST=unix:///var/run/docker.sock
0 commit comments