Skip to content

Commit 56f2b45

Browse files
msukkariclaude
andcommitted
perf: add --immutable to Docker installs and combine runner layers
Add --immutable flag to all yarn install commands in Docker for reproducible builds (prevents lockfile modifications). Combine sequential RUN commands in the runner stage to reduce final image layer count. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d2f9afd commit 56f2b45

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

Dockerfile

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ COPY ./packages/web/package.json ./packages/web/package.json
4747
COPY ./packages/backend/package.json ./packages/backend/package.json
4848
COPY ./packages/mcp/package.json ./packages/mcp/package.json
4949

50-
RUN yarn install --mode=skip-build
50+
RUN yarn install --immutable --mode=skip-build
5151

5252
# Step 2: Copy source files and build explicitly in topological order.
5353
COPY ./packages/db ./packages/db
@@ -107,7 +107,7 @@ COPY ./packages/queryLanguage/package.json ./packages/queryLanguage/package.json
107107
COPY ./packages/backend/package.json ./packages/backend/package.json
108108
COPY ./packages/mcp/package.json ./packages/mcp/package.json
109109

110-
RUN yarn install --mode=skip-build && \
110+
RUN yarn install --immutable --mode=skip-build && \
111111
yarn workspace @sourcebot/db prisma:generate
112112

113113
# Step 2: Copy pre-built shared libraries.
@@ -158,7 +158,7 @@ COPY ./packages/queryLanguage/package.json ./packages/queryLanguage/package.json
158158
COPY ./packages/web/package.json ./packages/web/package.json
159159
COPY ./packages/mcp/package.json ./packages/mcp/package.json
160160

161-
RUN yarn install --mode=skip-build && \
161+
RUN yarn install --immutable --mode=skip-build && \
162162
yarn workspace @sourcebot/db prisma:generate
163163

164164
# Step 2: Copy pre-built shared libraries and backend source.
@@ -243,8 +243,8 @@ COPY .yarn ./.yarn
243243

244244
# Configure zoekt
245245
COPY vendor/zoekt/install-ctags-alpine.sh .
246-
RUN ./install-ctags-alpine.sh && rm install-ctags-alpine.sh
247-
RUN mkdir -p ${DATA_CACHE_DIR}
246+
RUN ./install-ctags-alpine.sh && rm install-ctags-alpine.sh && \
247+
mkdir -p ${DATA_CACHE_DIR}
248248
COPY --from=zoekt-builder \
249249
/cmd/zoekt-git-index \
250250
/cmd/zoekt-indexserver \
@@ -276,19 +276,14 @@ COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/shared
276276
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/queryLanguage ./packages/queryLanguage
277277

278278
# Fixes git "dubious ownership" issues when the volume is mounted with different permissions to the container.
279-
RUN git config --global safe.directory "*"
280-
281-
# Configure the database
282-
RUN mkdir -p /run/postgresql && \
279+
RUN git config --global safe.directory "*" && \
280+
mkdir -p /run/postgresql && \
283281
chown -R postgres:postgres /run/postgresql && \
284-
chmod 775 /run/postgresql
285-
286-
# Make app directory accessible to both root and sourcebot user
287-
RUN chown -R sourcebot /app \
288-
&& chgrp -R 0 /app \
289-
&& chmod -R g=u /app
290-
# Make data directory accessible to both root and sourcebot user
291-
RUN chown -R sourcebot /data
282+
chmod 775 /run/postgresql && \
283+
chown -R sourcebot /app && \
284+
chgrp -R 0 /app && \
285+
chmod -R g=u /app && \
286+
chown -R sourcebot /data
292287

293288
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
294289
COPY prefix-output.sh ./prefix-output.sh

0 commit comments

Comments
 (0)