Skip to content

Commit 4bf6562

Browse files
authored
Update Dockerfiles and docker-compose.yml files (#742)
1 parent e793be9 commit 4bf6562

7 files changed

Lines changed: 50 additions & 42 deletions

File tree

Dockerfile

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
# Base OS
2-
FROM debian
2+
FROM ubuntu:24.04
33

4-
# Install baseline
4+
# Update package list & install some basic tools we'll need.
55
RUN apt-get update
6-
RUN apt-get install -y g++ make wget
6+
RUN apt-get install -y python3-dev python3-pip python3-venv make g++ wget git
77

8-
# Copy relevant files for simulation
8+
# Ubuntu 24's version of CMake is 3.28. We need a newer version.
9+
RUN apt-get remove --purge --auto-remove cmake
10+
RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.31.7/cmake-3.31.7-linux-x86_64.sh
11+
RUN sh cmake-3.31.7-linux-x86_64.sh --prefix=/usr/local --skip-license
12+
13+
# Copy relevant files for simulation.
914
COPY ./Makefile /qsim/Makefile
1015
COPY ./apps/ /qsim/apps/
1116
COPY ./circuits/ /qsim/circuits/
1217
COPY ./lib/ /qsim/lib/
18+
COPY ./requirements.txt /qsim/requirements.txt
19+
COPY ./dev-requirements.txt /qsim/dev-requirements.txt
1320

14-
WORKDIR /qsim/
21+
# Create venv to avoid collision between system packages and what we install.
22+
RUN python3 -m venv --upgrade-deps test_env
23+
24+
# Activate venv.
25+
ENV PATH="/test_env/bin:$PATH"
1526

16-
# Compile qsim
27+
# Install qsim requirements.
28+
RUN python3 -m pip install -r /qsim/requirements.txt
29+
RUN python3 -m pip install -r /qsim/dev-requirements.txt
30+
31+
# Compile qsim.
32+
WORKDIR /qsim/
1733
RUN make qsim
1834

1935
ENTRYPOINT ["/qsim/apps/qsim_base.x"]

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3"
21
services:
32
qsim:
43
image: qsim
@@ -21,4 +20,4 @@ services:
2120
context: ./
2221
dockerfile: pybind_interface/Dockerfile
2322
depends_on:
24-
- qsim
23+
- qsim

install/tests/Dockerfile

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
# Base OS
2-
FROM debian
2+
FROM ubuntu:24.04
33

4-
# Install requirements
4+
# Update package list & install some basic tools we'll need.
55
RUN apt-get update
6-
RUN apt-get install -y python3-dev python3-pip python3-venv
7-
RUN apt-get install -y cmake git
6+
RUN apt-get install -y python3-dev python3-pip python3-venv make g++ wget git
87

9-
# Create venv to avoid collision between system packages (e.g. numpy) and Cirq's deps.
10-
RUN python3 -m venv test_env
11-
12-
# Activate venv.
13-
ENV PATH="test_env/bin:$PATH"
8+
# Ubuntu 24's version of CMake is 3.28. We need a newer version.
9+
RUN apt-get remove --purge --auto-remove cmake
10+
RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.31.7/cmake-3.31.7-linux-x86_64.sh
11+
RUN sh cmake-3.31.7-linux-x86_64.sh --prefix=/usr/local --skip-license
1412

13+
# Copy qsim files from the outside-Docker location to an inside-Docker location.
1514
COPY ./ /qsim/
16-
RUN pip3 install /qsim/
1715

18-
# Run test in a non-qsim directory
16+
# Switch to that location.
17+
WORKDIR /qsim/
18+
19+
# Create venv to avoid collision between system packages and what we install.
20+
RUN python3 -m venv --upgrade-deps /qsim/test_env
21+
22+
# Activate the venv.
23+
ENV PATH="/qsim/test_env/bin:$PATH"
24+
25+
# Install qsim from sources.
26+
# Note: use pip3 here, not python3 -m pip. We need to make sure to get the pip
27+
# installed inside the venv, because that one has the correct sys.path.
28+
RUN pip3 install -v /qsim/
29+
30+
# Copy the tests to a non-qsim directory.
1931
COPY ./qsimcirq_tests/ /test-install/
2032

33+
# Run the tests from that location.
2134
WORKDIR /test-install/
22-
2335
ENTRYPOINT python3 -m pytest ./

install/tests/docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3"
21
services:
32
# Verifies that installing from the `qsimcirq` PyPI package works correctly.
43
# To ensure that users do not need to clone the qsim repository in order to
@@ -8,4 +7,4 @@ services:
87
container_name: qsim-install
98
build:
109
context: ../../
11-
dockerfile: ./install/tests/Dockerfile
10+
dockerfile: ./install/tests/Dockerfile

jupyter/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Base OS
2-
FROM debian:bullseye
2+
FROM ubuntu:24.04
33
USER root
44

55
# Install baseline

pybind_interface/Dockerfile

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
# Base OS
22
FROM qsim
33

4-
# Install additional requirements
5-
RUN apt-get install -y python3-dev python3-pybind11 python3-pip python3-venv
6-
7-
# Create venv to avoid collision between system packages (e.g. numpy) and Cirq's deps.
8-
RUN python3 -m venv test_env
9-
10-
# Activate venv.
11-
ENV PATH="test_env/bin:$PATH"
12-
13-
# break-system-packages flag to override system packages (e.g. numpy) with Cirq's deps.
14-
RUN pip3 install --prefer-binary cirq-core
15-
164
# Copy relevant files
175
COPY ./pybind_interface/ /qsim/pybind_interface/
186
COPY ./qsimcirq/ /qsim/qsimcirq/
@@ -23,8 +11,5 @@ WORKDIR /qsim/
2311
# Build pybind code early to cache the results
2412
RUN make -C /qsim/ pybind
2513

26-
# Install pytest
27-
RUN pip3 install pytest
28-
2914
# Compile and run qsim tests
3015
ENTRYPOINT make -C /qsim/ run-py-tests

tests/Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
# Base OS
22
FROM qsim
33

4-
# Install additional requirements
5-
RUN apt-get install -y cmake git
6-
74
# Copy relevant files
85
COPY ./tests/ /qsim/tests/
96

107
WORKDIR /qsim/
118

129
# Compile and run qsim tests
13-
ENTRYPOINT make -C /qsim/ run-cxx-tests
10+
ENTRYPOINT make -C /qsim/ run-cxx-tests

0 commit comments

Comments
 (0)