Skip to content

Fix docker #4230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6f394ec
Modify DockerFile
shivanth Jun 19, 2021
a40d374
Modify docker usage command to use new package name
shivanth Jun 19, 2021
3a621cf
Merge branch 'master' into fix_docker
shivanth Jun 22, 2021
d1c7101
docker test
shivanth Jun 23, 2021
9ca81cd
add marker for docker test
shivanth Jun 23, 2021
f0b03b3
format
shivanth Jun 23, 2021
3193ba4
Merge branch 'master' into fix_docker
shivanth Jun 23, 2021
0c1381d
Add docker test
shivanth Jun 23, 2021
a9e061c
:wqMerge branch 'fix_docker' of github.com:shivanth/Cirq into fix_docker
shivanth Jun 23, 2021
d34a7b2
register marker
shivanth Jun 23, 2021
87b9d6a
Modify DockerFile
shivanth Jun 19, 2021
5e60e80
Modify docker usage command to use new package name
shivanth Jun 19, 2021
dcccad5
docker test
shivanth Jun 23, 2021
8164c12
add marker for docker test
shivanth Jun 23, 2021
ed98b3a
format
shivanth Jun 23, 2021
8353e76
Add docker test
shivanth Jun 23, 2021
6c63fb6
register marker
shivanth Jun 23, 2021
5a674b8
Remove marker for docker
shivanth Jun 23, 2021
121cd2f
Merge branch 'fix_docker' of github.com:shivanth/Cirq into fix_docker
shivanth Jun 23, 2021
faf3254
remove tags
shivanth Jun 23, 2021
17b2c62
fix lint
shivanth Jun 23, 2021
4c34f48
Merge branch 'master' into fix_docker
shivanth Jun 23, 2021
d1ce259
Fix docker file
shivanth Jun 24, 2021
01afe06
Merge branch 'fix_docker' of github.com:shivanth/Cirq into fix_docker
shivanth Jun 24, 2021
93526cc
fmt
shivanth Jun 24, 2021
5182712
Merge branch 'master' into fix_docker
shivanth Jun 24, 2021
7dd8aa2
remove commented
shivanth Jun 24, 2021
96b964c
Merge branch 'fix_docker' of github.com:shivanth/Cirq into fix_docker
shivanth Jun 24, 2021
b3ba7b9
Add pre release images
shivanth Jun 25, 2021
9a738f9
Merge branch 'master' into fix_docker
shivanth Jun 25, 2021
8b50d53
Update doc
shivanth Jun 26, 2021
865153e
Merge branch 'master' into fix_docker
shivanth Jun 26, 2021
ec75028
Merge branch 'master' into fix_docker
shivanth Jun 29, 2021
b59cfb6
Merge branch 'master' into fix_docker
shivanth Jun 30, 2021
ff5eccc
Merge branch 'master' into fix_docker
CirqBot Jun 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 6 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
FROM python:3.8-slim AS compile-image
FROM python:3.8-slim AS cirq_base

# Install dependencies.
# rm -rf /var/lib/apt/lists/* cleans up apt cache. See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
python3-pip \
python3-tk \
texlive-latex-base \
latexmk \
git \
locales \
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -21,28 +17,10 @@ ENV LC_ALL en_US.UTF-8
# Make python3 default
RUN rm -f /usr/bin/python \
&& ln -s /usr/bin/python3 /usr/bin/python

# Create a virtual enironment to copy over into
# the final docker image
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Copy current folder instead of cloning.
COPY ./ .
COPY requirements.txt .
COPY ./cirq/contrib/contrib-requirements.txt .
COPY ./dev_tools/conf/pip-list-dev-tools.txt .

RUN pip3 install -r requirements.txt -r contrib-requirements.txt -r pip-list-dev-tools.txt

# Install cirq
#cirq stable image
FROM cirq_base AS cirq_stable
RUN pip3 install cirq

FROM python:3.8-slim AS build-image
COPY --from=compile-image /opt/venv /opt/venv

# Make sure scripts in .local are usable:
ENV PATH="/opt/venv/bin:$PATH"

WORKDIR /Cirq
EXPOSE 8888
##cirq pre_release image
FROM cirq_base AS cirq_pre_release
RUN pip3 install cirq --pre
48 changes: 0 additions & 48 deletions dev_tools/Dockerfile

This file was deleted.

39 changes: 39 additions & 0 deletions dev_tools/docker_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import subprocess
import pathlib
import platform
import pytest


def test_docker_stable():
if platform.system() != 'Linux':
pytest.skip("Unsupported os")
root_folder = pathlib.Path(__file__).parent.parent
buildResult = subprocess.run(
['docker', 'build', '--target', 'cirq_stable', '-t', 'cirq_image', '.'], cwd=root_folder
)
assert buildResult.returncode == 0

result = subprocess.run(
['docker run cirq_image python -c "import cirq; assert cirq.__version__ is not None"'],
cwd=root_folder,
shell=True,
)
assert result.returncode == 0


def test_docker_pre():
if platform.system() != 'Linux':
pytest.skip("Unsupported os")
root_folder = pathlib.Path(__file__).parent.parent
buildResult = subprocess.run(
['docker', 'build', '--target', 'cirq_pre_release', '-t', 'cirq_image_pre', '.'],
cwd=root_folder,
)
assert buildResult.returncode == 0

result = subprocess.run(
['docker run cirq_image_pre python -c "import cirq; assert cirq.__version__ is not None"'],
cwd=root_folder,
shell=True,
)
assert result.returncode == 0
10 changes: 7 additions & 3 deletions docs/dev/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ git config blame.ignoreRevsFile .git-blame-ignore-revs
Note that if you are using PyCharm, you might have to Restart & Invalidate Caches to have the change being picked up.

## Docker
You can build the stable and pre_release docker images with our `Dockerfile`.

To do your development in a Docker image, you can build one with our `Dockerfile`.
```bash
docker build -t cirq .
docker run -it cirq python -c "import cirq; print(cirq.google.Foxtail)"
docker build -t cirq --target cirq_stable .
docker run -it cirq python -c "import cirq_google; print(cirq_google.Foxtail)"
```

```bash
docker build -t cirq_pre --target cirq_pre_release .
docker run -it cirq_pre python -c "import cirq_google; print(cirq_google.Foxtail)"
```

If you want to contribute changes to Cirq, you will instead want to fork the repository and submit pull requests from your fork.

Expand Down