Skip to content

Commit 86d31dc

Browse files
committed
Prefer buildctx to bind-mounts for prebuilt binaries
This is a little slower, but it removes a whole bunch of permission errors that can arise if docker users don't belong to certain groups.
1 parent b4f3ec1 commit 86d31dc

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ plots/
55
artefacts/
66
src/
77
!src/parserbench
8+
!artefacts/prebuilt

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ FROM base as build
77
WORKDIR /app
88

99
# Add build argument for prebuilt binaries
10-
ARG PREBUILT_BINS=false
10+
ARG BUILD_QUICK=false
11+
ENV BUILD_QUICK=${BUILD_QUICK}
1112

1213
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
1314
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
@@ -42,13 +43,15 @@ RUN --mount=type=cache,target=/root/.cache/pip \
4243
pip install --upgrade pip --break-system-packages && \
4344
pip install .[dev] --break-system-packages
4445

46+
RUN mkdir -p /app/artefacts
47+
4548
COPY . .
4649

47-
RUN --mount=type=cache,target=/app/artefacts \
48-
if [ "$PREBUILT_BINS" = "false" ]; then \
50+
RUN if [ "$BUILD_QUICK" = "false" ]; then \
4951
invoke build-benchmarks; \
5052
else \
5153
echo "Using prebuilt binaries"; \
54+
cp -r ./artefacts/prebuilt /app/artefacts/; \
5255
fi
5356

5457

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ run-quick: fetch-binaries
3232
docker buildx build \
3333
--target runtime \
3434
--tag $(IMAGE_quick) \
35-
--build-arg PREBUILT_BINS=true \
35+
--build-arg QUICK_BUILD=true \
3636
--load .
3737
@test -f $(LOGFILE) || touch $(LOGFILE)
3838
chmod a+w $(LOGFILE)
3939
docker run --rm -it \
4040
--mount type=bind,source="$(LOGFILE)",target=/app/experiment.log \
4141
--mount type=bind,source="$(RESULTS)",target=/app/results \
42-
--mount type=bind,source="$(PREBUILT_BIN)",target=/app/artefacts/bin \
4342
$(IMAGE_quick)
4443

4544
run-full:

0 commit comments

Comments
 (0)