Skip to content

Commit ac0b4f0

Browse files
authored
Fix #858 by splitting up docker compose build (#860)
1 parent 2acea90 commit ac0b4f0

7 files changed

Lines changed: 43 additions & 28 deletions

File tree

.github/workflows/ci_docker_tests.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ jobs:
6666
submodules: recursive
6767

6868
- name: Build Docker images
69-
run: docker compose build
69+
run: |
70+
# Running locally, a plain "docker compose build" works as expected.
71+
# On GitHub, buildx tries to build all 3 images in parallel even if
72+
# you set COMPOSE_PARALLEL_LIMIT or use --parallel 1. That fails b/c
73+
# the qsim-base image is not available to the other two build jobs.
74+
docker compose build qsim-base-image
75+
docker compose build qsim-cxx-tests-image qsim-py-tests-image
7076
7177
- name: Run C++ tests
7278
run: docker run --rm qsim-cxx-tests:latest
@@ -75,7 +81,7 @@ jobs:
7581
run: docker run --rm qsim-py-tests:latest
7682

7783
- name: Run a sample simulation
78-
run: docker run --rm qsim:latest -c /qsim/circuits/circuit_q24
84+
run: docker run --rm qsim-base:latest -c /qsim/circuits/circuit_q24
7985

8086
- name: Test installation process
8187
run: |

Dockerfile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# Base OS
2-
FROM ubuntu:24.04
2+
FROM ubuntu:24.04 AS qsim-base
33

44
# Allow passing this variable in from the outside.
55
ARG CUDA_PATH
66
ENV PATH="$CUDA_PATH/bin:$PATH"
77

88
# Update package list & install some basic tools we'll need.
9-
RUN apt-get update
10-
RUN apt-get install -y python3-dev python3-pip python3-venv make g++ wget git
9+
# hadolint ignore=DL3009,DL3008
10+
RUN apt-get update && \
11+
apt-get install -y make g++ wget git --no-install-recommends && \
12+
apt-get install -y python3-dev python3-pip python3-venv --no-install-recommends
1113

1214
# Ubuntu 24's version of CMake is 3.28. We need a newer version.
1315
RUN apt-get remove --purge --auto-remove cmake
14-
RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.31.7/cmake-3.31.7-linux-x86_64.sh
15-
RUN sh cmake-3.31.7-linux-x86_64.sh --prefix=/usr/local --skip-license
16+
RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.31.7/cmake-3.31.7-linux-x86_64.sh && \
17+
sh cmake-3.31.7-linux-x86_64.sh --prefix=/usr/local --skip-license
1618

1719
# Copy relevant files for simulation.
1820
COPY ./Makefile /qsim/Makefile
@@ -31,8 +33,9 @@ RUN python3 -m venv --upgrade-deps test_env
3133
ENV PATH="/test_env/bin:$PATH"
3234

3335
# Install qsim requirements.
34-
RUN python3 -m pip install -r /qsim/requirements.txt
35-
RUN python3 -m pip install -r /qsim/dev-requirements.txt
36+
# hadolint ignore=DL3042
37+
RUN python3 -m pip install -r /qsim/requirements.txt && \
38+
python3 -m pip install -r /qsim/dev-requirements.txt
3639

3740
# Compile qsim.
3841
WORKDIR /qsim/

docker-compose.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
services:
2-
qsim:
3-
image: qsim
4-
container_name: qsim
2+
qsim-base-image:
3+
image: qsim-base
4+
platform: linux/amd64
55
build:
66
context: ./
77
dockerfile: Dockerfile
8-
qsim-cxx-tests:
8+
target: qsim-base
9+
10+
qsim-cxx-tests-image:
911
image: qsim-cxx-tests
10-
container_name: qsim-cxx-tests
1112
build:
1213
context: ./
1314
dockerfile: tests/Dockerfile
15+
target: qsim-cxx-tests
1416
depends_on:
15-
- qsim
16-
qsim-py-tests:
17+
- qsim-base-image
18+
19+
qsim-py-tests-image:
1720
image: qsim-py-tests
18-
container_name: qsim-py-tests
1921
build:
2022
context: ./
2123
dockerfile: pybind_interface/Dockerfile
24+
target: qsim-py-tests
2225
depends_on:
23-
- qsim
26+
- qsim-base-image

install/tests/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ ARG CUDA_PATH
66
ENV PATH="$CUDA_PATH/bin:$PATH"
77

88
# Update package list & install some basic tools we'll need.
9-
RUN apt-get update
10-
RUN apt-get install -y python3-dev python3-pip python3-venv make g++ wget git
9+
# hadolint ignore=DL3009,DL3008
10+
RUN apt-get update && \
11+
apt-get install -y make g++ wget git --no-install-recommends && \
12+
apt-get install -y python3-dev python3-pip python3-venv --no-install-recommends
1113

1214
# Ubuntu 24's version of CMake is 3.28. We need a newer version.
1315
RUN apt-get remove --purge --auto-remove cmake
14-
RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.31.7/cmake-3.31.7-linux-x86_64.sh
15-
RUN sh cmake-3.31.7-linux-x86_64.sh --prefix=/usr/local --skip-license
16+
RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.31.7/cmake-3.31.7-linux-x86_64.sh && \
17+
sh cmake-3.31.7-linux-x86_64.sh --prefix=/usr/local --skip-license
1618

1719
# Copy qsim files from the outside-Docker location to an inside-Docker location.
1820
COPY ./ /qsim/
@@ -29,6 +31,7 @@ ENV PATH="/qsim/test_env/bin:$PATH"
2931
# Install qsim from sources.
3032
# Note: use pip3 here, not python3 -m pip. We need to make sure to get the pip
3133
# installed inside the venv, because that one has the correct sys.path.
34+
# hadolint ignore=DL3042
3235
RUN pip3 install -v /qsim/
3336

3437
# Copy the tests to a non-qsim directory.

pybind_interface/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Base OS
2-
FROM qsim
2+
FROM qsim-base AS qsim-py-tests
33

44
# Copy relevant files
55
COPY ./pybind_interface/ /qsim/pybind_interface/

tests/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Base OS
2-
FROM qsim
2+
FROM qsim-base AS qsim-cxx-tests
33

44
# Copy relevant files
55
COPY ./tests/ /qsim/tests/

tests/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,19 @@ custatevec-tests: $(CUSTATEVEC_TARGETS)
7070
hip-tests: $(HIP_TARGETS)
7171

7272
.PHONY: run-cxx-tests
73-
run-cxx-tests: cxx-tests
73+
run-cxx-tests: | $(GTEST_DIR)/build cxx-tests
7474
for exe in $(CXX_TARGETS); do if ! ./$$exe; then exit 1; fi; done
7575

7676
.PHONY: run-cuda-tests
77-
run-cuda-tests: cuda-tests
77+
run-cuda-tests: | $(GTEST_DIR)/build cuda-tests
7878
for exe in $(CUDA_TARGETS); do if ! ./$$exe; then exit 1; fi; done
7979

8080
.PHONY: run-custatevec-tests
81-
run-custatevec-tests: custatevec-tests
81+
run-custatevec-tests: | $(GTEST_DIR)/build custatevec-tests
8282
for exe in $(CUSTATEVEC_TARGETS); do if ! ./$$exe; then exit 1; fi; done
8383

8484
.PHONY: run-hip-tests
85-
run-hip-tests: hip-tests
85+
run-hip-tests: | $(GTEST_DIR)/build hip-tests
8686
for exe in $(HIP_TARGETS); do if ! ./$$exe; then exit 1; fi; done
8787

8888
$(GTEST_DIR)/build:

0 commit comments

Comments
 (0)