diff --git a/.github/workflows/ci_docker_tests.yaml b/.github/workflows/ci_docker_tests.yaml index 55698f401..77bf452c4 100644 --- a/.github/workflows/ci_docker_tests.yaml +++ b/.github/workflows/ci_docker_tests.yaml @@ -66,7 +66,13 @@ jobs: submodules: recursive - name: Build Docker images - run: docker compose build + run: | + # Running locally, a plain "docker compose build" works as expected. + # On GitHub, buildx tries to build all 3 images in parallel even if + # you set COMPOSE_PARALLEL_LIMIT or use --parallel 1. That fails b/c + # the qsim-base image is not available to the other two build jobs. + docker compose build qsim-base-image + docker compose build qsim-cxx-tests-image qsim-py-tests-image - name: Run C++ tests run: docker run --rm qsim-cxx-tests:latest @@ -75,7 +81,7 @@ jobs: run: docker run --rm qsim-py-tests:latest - name: Run a sample simulation - run: docker run --rm qsim:latest -c /qsim/circuits/circuit_q24 + run: docker run --rm qsim-base:latest -c /qsim/circuits/circuit_q24 - name: Test installation process run: | diff --git a/Dockerfile b/Dockerfile index 1d7fdcefd..85f272f37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Base OS -FROM ubuntu:24.04 +FROM ubuntu:24.04 AS qsim-base # Allow passing this variable in from the outside. ARG CUDA_PATH diff --git a/docker-compose.yml b/docker-compose.yml index 0b63bb418..0cffe39ae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,23 +1,26 @@ services: - qsim: - image: qsim - container_name: qsim + qsim-base-image: + image: qsim-base + platform: linux/amd64 build: context: ./ dockerfile: Dockerfile - qsim-cxx-tests: + target: qsim-base + + qsim-cxx-tests-image: image: qsim-cxx-tests - container_name: qsim-cxx-tests build: context: ./ dockerfile: tests/Dockerfile + target: qsim-cxx-tests depends_on: - - qsim - qsim-py-tests: + - qsim-base-image + + qsim-py-tests-image: image: qsim-py-tests - container_name: qsim-py-tests build: context: ./ dockerfile: pybind_interface/Dockerfile + target: qsim-py-tests depends_on: - - qsim + - qsim-base-image diff --git a/pybind_interface/Dockerfile b/pybind_interface/Dockerfile index 22f043480..d22ba9911 100644 --- a/pybind_interface/Dockerfile +++ b/pybind_interface/Dockerfile @@ -1,5 +1,5 @@ # Base OS -FROM qsim +FROM qsim-base AS qsim-py-tests # Copy relevant files COPY ./pybind_interface/ /qsim/pybind_interface/ diff --git a/tests/Dockerfile b/tests/Dockerfile index f83b25aa6..2e37212c6 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,5 +1,5 @@ # Base OS -FROM qsim +FROM qsim-base AS qsim-cxx-tests # Copy relevant files COPY ./tests/ /qsim/tests/