Skip to content

Commit

Permalink
Simplify Docker image (pyodide#815)
Browse files Browse the repository at this point in the history
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
  • Loading branch information
dalcde and rth authored Dec 6, 2020
1 parent 411a058 commit 81df4e2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 58 deletions.
26 changes: 8 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
defaults: &defaults
working_directory: ~/repo
docker:
- image: iodide/pyodide-env:0.16.1
- image: iodide/pyodide-env:8
environment:
- EMSDK_NUM_CORES: 4
EMCC_CORES: 4
Expand All @@ -19,7 +19,7 @@ jobs:
command: |
pip install black mypy
# TODO: investigate why clang-format without version is not available
sudo ln -s /usr/bin/clang-format-6.0 /usr/bin/clang-format
ln -s /usr/bin/clang-format-6.0 /usr/bin/clang-format
make lint
black --check --exclude tools/file_packager.py .
mypy --ignore-missing-imports pyodide_build/ src/ packages/micropip/micropip/ packages/*/test*
Expand All @@ -30,11 +30,7 @@ jobs:

- restore_cache:
keys:
- v1-emsdk-{{ checksum "emsdk/Makefile" }}-v20201203-

- run:
name: dependencies
command: sudo apt install -y libtinfo5
- v1-emsdk-{{ checksum "emsdk/Makefile" }}-v20201205-

- run:
name: build
Expand All @@ -52,7 +48,7 @@ jobs:
paths:
- ./emsdk/emsdk
- ~/.ccache
key: v1-emsdk-{{ checksum "emsdk/Makefile" }}-v20201203-{{ .BuildNum }}
key: v1-emsdk-{{ checksum "emsdk/Makefile" }}-v20201205-{{ .BuildNum }}

- persist_to_workspace:
root: .
Expand All @@ -71,11 +67,7 @@ jobs:
# this cache is generated by the main build job, we never store it here
- restore_cache:
keys:
- v1-emsdk-{{ checksum "emsdk/Makefile" }}-v20201203-

- run:
name: dependencies
command: sudo apt install -y libtinfo5
- v1-emsdk-{{ checksum "emsdk/Makefile" }}-v20201205-

- run:
name: build
Expand Down Expand Up @@ -108,8 +100,7 @@ jobs:
- run:
name: test
command: |
pip install pytest-httpserver
pytest src packages/*/test* packages/micropip/micropip/ pyodide_build -v -k firefox
pytest src packages/*/test* pyodide_build -v -k firefox
test-chrome:
<<: *defaults
Expand All @@ -120,8 +111,7 @@ jobs:
- run:
name: test
command: |
pip install pytest-httpserver
pytest src packages/*/test* packages/micropip/micropip/ pyodide_build -v -k chrome
pytest src packages/*/test* pyodide_build -v -k chrome
test-python:
<<: *defaults
Expand All @@ -130,7 +120,7 @@ jobs:
- run:
name: deps
command: |
sudo pip install pytest-cov
pip install pytest-cov
- run:
name: test
command: |
Expand Down
53 changes: 19 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,29 @@
FROM circleci/python:3.8.2-buster

RUN sudo apt-get update \
# bzip2 and libgconf-2-4 are necessary for extracting firefox and running chrome, respectively
&& sudo apt-get install bzip2 libgconf-2-4 node-less cmake build-essential clang-format-6.0 \
uglifyjs chromium ccache libncurses6 gfortran f2c swig g++-8 libtinfo5 \
&& sudo apt-get clean \
&& sudo apt-get autoremove \
FROM python:3.8.2-buster

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
# building packages
bzip2 ccache clang-format-6.0 cmake f2c g++ gfortran libtinfo5 node-less swig uglifyjs \
# testing packages: libgconf-2-4 is necessary for running chromium
libgconf-2-4 chromium \
&& rm -rf /var/lib/apt/lists/* \
&& test "Comment: Hardcode nodejs path for uglifyjs, so it doesn't conflict with emcc's nodejs" \
&& test $(which node) = /usr/bin/node && test $(which uglifyjs) = /usr/bin/uglifyjs \
&& echo '#!/bin/sh -e\nexec /usr/bin/node /usr/bin/uglifyjs "$@"' >/tmp/uglifyjs \
&& chmod a+x /tmp/uglifyjs && sudo mv -t /usr/local/bin /tmp/uglifyjs
&& chmod a+x /tmp/uglifyjs && mv -t /usr/local/bin /tmp/uglifyjs

RUN sudo pip install pytest pytest-xdist pytest-instafail pytest-rerunfailures selenium PyYAML flake8 \
&& sudo rm -rf /root/.cache/pip
RUN pip3 --no-cache-dir install pytest pytest-xdist pytest-instafail pytest-rerunfailures pytest-httpserver selenium PyYAML flake8

# Get recent version of Firefox and geckodriver
RUN sudo wget --quiet -O firefox.tar.bz2 https://ftp.mozilla.org/pub/firefox/releases/70.0.1/linux-x86_64/en-US/firefox-70.0.1.tar.bz2 \
&& sudo tar jxf firefox.tar.bz2 \
&& sudo rm -f /usr/local/bin/firefox \
&& sudo ln -s $PWD/firefox/firefox /usr/local/bin/firefox \
&& sudo wget --quiet https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz \
&& sudo tar zxf geckodriver-v0.26.0-linux64.tar.gz -C /usr/local/bin \
&& sudo rm -f firefox.tar.bz2 geckodriver-v0.26.0-linux64.tar.gz
# Get firefox 70.0.1 and geckodriver
RUN wget -qO- https://ftp.mozilla.org/pub/firefox/releases/70.0.1/linux-x86_64/en-US/firefox-70.0.1.tar.bz2 | tar jx \
&& ln -s $PWD/firefox/firefox /usr/local/bin/firefox \
&& wget -qO- https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz | tar zxC /usr/local/bin/

# Get recent version of chromedriver
RUN sudo wget --quiet https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip \
&& sudo unzip chromedriver_linux64.zip \
&& sudo mv $PWD/chromedriver /usr/local/bin \
&& sudo rm -f chromedriver_linux64.zip


# start xvfb automatically to avoid needing to express in circle.yml
ENV DISPLAY :99
RUN printf '#!/bin/sh\nXvfb :99 -screen 0 1280x1024x24 &\nexec "$@"\n' > /tmp/entrypoint \
&& chmod +x /tmp/entrypoint \
&& sudo mv /tmp/entrypoint /docker-entrypoint.sh

# ensure that the build agent doesn't override the entrypoint
LABEL com.circleci.preserve-entrypoint=true
RUN wget --quiet https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip \
&& unzip chromedriver_linux64.zip \
&& mv $PWD/chromedriver /usr/local/bin \
&& rm -f chromedriver_linux64.zip

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/bin/sh"]
WORKDIR /src
5 changes: 0 additions & 5 deletions docs/building_from_sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ building on the host machine is preferred if at all possible.

2. From a git checkout of Pyodide, run `./run_docker` or `./run_docker --pre-built`

Install libtinfo5 in the docker contaner,
```
sudo apt install -y libtinfo5
```

3. Run `make` to build.

Note: You can control the resources allocated to the build by setting the env vars
Expand Down
2 changes: 1 addition & 1 deletion run_docker
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function error() {
}


PYODIDE_IMAGE_TAG="0.16.1"
PYODIDE_IMAGE_TAG="8"
PYODIDE_PREBUILT_IMAGE_TAG="0.16.0b1"
DEFAULT_PYODIDE_DOCKER_IMAGE="iodide/pyodide-env:${PYODIDE_IMAGE_TAG}"
DEFAULT_PYODIDE_SYSTEM_PORT="8000"
Expand Down

0 comments on commit 81df4e2

Please sign in to comment.