Skip to content

Commit 4548548

Browse files
authored
docker: share image definitions between local docker compose and taskcluster (#3564)
The only real difference is the location of the source, which is under topsrcdir in TC. Use a build argument to deal with that.
1 parent 562acb8 commit 4548548

File tree

5 files changed

+23
-87
lines changed

5 files changed

+23
-87
lines changed

Dockerfile

Lines changed: 0 additions & 44 deletions
This file was deleted.

agent/Dockerfile

Lines changed: 0 additions & 27 deletions
This file was deleted.

docker-compose.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ services:
66
balrogadmin:
77
build:
88
context: .
9+
dockerfile: taskcluster/docker/balrog-backend/Dockerfile
910
args:
1011
PYTHON_VERSION: 3.13
12+
SRC: .
1113
depends_on:
1214
balrogdb:
1315
condition: service_healthy
@@ -61,8 +63,10 @@ services:
6163
balrogpub:
6264
build:
6365
context: .
66+
dockerfile: taskcluster/docker/balrog-backend/Dockerfile
6467
args:
6568
PYTHON_VERSION: 3.13
69+
SRC: .
6670
depends_on:
6771
balrogdb:
6872
condition: service_healthy
@@ -100,9 +104,10 @@ services:
100104
balrogagent:
101105
build:
102106
context: .
103-
dockerfile: agent/Dockerfile
107+
dockerfile: taskcluster/docker/balrog-agent/Dockerfile
104108
args:
105109
PYTHON_VERSION: 3.13
110+
SRC: .
106111
depends_on:
107112
nginx:
108113
condition: service_healthy

taskcluster/docker/balrog-agent/Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
# WARNING: keep this file in sync with agent/Dockerfile
2-
31
ARG PYTHON_VERSION=3.13
42
FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-bookworm-slim AS builder
53

64
WORKDIR /app
75

6+
# Use an arg so we can share the Dockerfile with docker compose
7+
ARG SRC=topsrcdir
8+
89
# %include pyproject.toml
910
# %include uv.lock
1011
# %include README.rst
11-
COPY topsrcdir/pyproject.toml topsrcdir/uv.lock topsrcdir/README.rst /app/
12+
COPY ${SRC}/pyproject.toml ${SRC}/uv.lock ${SRC}/README.rst /app/
1213

1314
# %include agent
14-
COPY topsrcdir/agent /app/agent
15+
COPY ${SRC}/agent /app/agent
1516

1617
RUN uv venv
1718
RUN uv sync --package=balrogagent --frozen --no-dev
@@ -26,9 +27,9 @@ COPY --from=builder /app/.venv /app/.venv
2627
# %include agent/scripts
2728
# %include agent/src
2829
# %include agent/run.sh
29-
COPY topsrcdir/agent/scripts/ /app/scripts/
30-
COPY topsrcdir/agent/src /app/agent/src
31-
COPY topsrcdir/agent/run.sh /app
30+
COPY ${SRC}/agent/scripts/ /app/scripts/
31+
COPY ${SRC}/agent/src /app/agent/src
32+
COPY ${SRC}/agent/run.sh /app
3233

3334
# Using /bin/bash as the entrypoint works around some volume mount issues on Windows
3435
# where volume-mounted files do not have execute bits set.

taskcluster/docker/balrog-backend/Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# WARNING: keep this file in sync with the main balrog Dockerfile
2-
31
ARG PYTHON_VERSION=3.13
42
FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-bookworm-slim AS builder
53

@@ -10,12 +8,15 @@ WORKDIR /app
108
RUN apt-get -q update \
119
&& apt-get -q --yes install g++ default-libmysqlclient-dev gcc pkg-config
1210

11+
# Use a variable so we can share the Dockerfile with docker compose
12+
ARG SRC=topsrcdir
13+
1314
# %include pyproject.toml
1415
# %include uv.lock
1516
# %include README.rst
16-
COPY topsrcdir/pyproject.toml topsrcdir/uv.lock topsrcdir/README.rst /app/
17+
COPY ${SRC}/pyproject.toml ${SRC}/uv.lock ${SRC}/README.rst /app/
1718
# %include src
18-
COPY topsrcdir/src/ /app/src/
19+
COPY ${SRC}/src/ /app/src/
1920

2021
RUN uv venv
2122
RUN uv sync --no-dev --frozen
@@ -37,13 +38,13 @@ WORKDIR /app
3738

3839
COPY --from=builder /app/.venv /app/.venv
3940
# %include src
40-
COPY topsrcdir/src/ /app/src/
41+
COPY ${SRC}/src/ /app/src/
4142
# %include scripts
42-
COPY topsrcdir/scripts/ /app/scripts/
43+
COPY ${SRC}/scripts/ /app/scripts/
4344
# %include uwsgi
44-
COPY topsrcdir/uwsgi/ /app/uwsgi/
45+
COPY ${SRC}/uwsgi/ /app/uwsgi/
4546
# %include version.json
46-
COPY topsrcdir/version.json /app/
47+
COPY ${SRC}/version.json /app/
4748

4849
ENV PATH="/app/.venv/bin:${PATH}"
4950

0 commit comments

Comments
 (0)