Skip to content
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

Create dedicated Dockerfile with Python 3.6 to reduce CI time #7352

Merged
merged 3 commits into from Mar 12, 2019

Conversation

Projects
None yet
3 participants
@Eric-Arellano
Copy link
Contributor

commented Mar 10, 2019

Problem

Every time we run a Docker shard, we spend about 3 minutes installing Python 3.6 and its dependencies, even if that shard never once uses Python 3. In particular, this slows down our Linux Build Wheels UCS4 shard and our Linux Build Engine Py2 for a collective cost of 6 minutes every CI run (i.e. total CI cost, not wall time).

Ideally, we would want Python 3 pre-installed on the base Centos6 image so that we never for any shard have to waste time installing Python 3 (see #7064). Until that lands, though, this is an additional unneeded burden.

Solution

Create a new image travis_ci_py36.

Thanks to how we can now parametrize the docker image name in travis.yml.mustache, this brings no additional cognitive overload to our .travis.yml, which was the original reason we did not create a duplicate Dockerfile.

Also does a little cleanup from #7351 in removing a bad env var $BOOTSTRAP_ARGS for the linux build engine shards.

@cosmicexplorer
Copy link
Contributor

left a comment

🔥 This is great! Working on making #7064 happen to burn down stage 1 CI time even more.

${PYENV_ROOT}/bin/pyenv install ${PYTHON_3_VERSION} \
&& ${PYENV_ROOT}/bin/pyenv global ${PYTHON_3_VERSION}'
ENV PATH "${PYENV_ROOT}/shims:${PATH}"

This comment has been minimized.

Copy link
@cosmicexplorer

cosmicexplorer Mar 11, 2019

Contributor

Does this end up making the first CI stage faster by 3 minutes in real time as well? Or are we still paying that cost when installing python 3 for the py 3 linux pex shard in stage 1, and the win here is just in overall time across all shards?

This comment has been minimized.

Copy link
@Eric-Arellano

Eric-Arellano Mar 11, 2019

Author Contributor

Unfortunately win is only in overall CI time, not in wall time. We still have to build Py36 for Linux Build Engine Py36, and soon the two wheel building shards for Py3.

Which is why #7064 will be so great! And your PR will also help with Py37 to save time with our cron job, once I figure out #7261.

Eric-Arellano added some commits Mar 11, 2019

Remove bad leftover env var from #7351
#7351 should have deleted $BOOTSTRAP_ARGS for the Linux Build engine shards. This does its cleanup.
@benjyw

benjyw approved these changes Mar 11, 2019

@Eric-Arellano Eric-Arellano merged commit f4cb117 into pantsbuild:master Mar 12, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:travis_ci_py36 branch Mar 12, 2019

Eric-Arellano added a commit to Eric-Arellano/pants that referenced this pull request Mar 12, 2019

Fix bad docker image from pantsbuild#7352
Now that we have a dedicated Docker image for Py36, we must explicitly point to this.

cosmicexplorer added a commit that referenced this pull request Apr 5, 2019

Install Python 2.7 and 3.6 on Centos6 base image through Pyenv (#7064)
### Problem

We have used a python 3 interpreter in CI for a while now, using `pyenv` to install this in our Dockerfiles instead of relying on CentOS's `scl` features, which don't allow for multiple pythons at a time. Using `pyenv` to install Python 2.7 as well instead of relying on the package manager allows us to upgrade or modify the image without screwing up our Python installation.

That work began in this PR and ended up in #6981, #7352, #7418, #7483, and more, but it then led to having to duplicate code across `travis_ci` and `travis_ci_py36` Dockerfiles. Using `pyenv` to install python in our `travis_ci` images also involves a significant setup time in bootstrap phases to install our desired pythons. Installing Python in the CentOS 6 base image avoids having to install Python at all in our CI, which saves us minutes in the bootstrap phase.

### Solution

- Use Pyenv to install Python 2.7 and Python 3.6 in the `centos6` Dockerfile.
- Remove `travis_cy_py36`.
- Modify the `travis_ci` Dockerfile to bootstrap pyenv itself if not available.

### Result

We get some CI time back in the bootstrap phase.

### TODO

- [ ] merge this PR
- [ ] publish the new `centos6` image to dockerhub at `pantsbuild/centos6:latest`
- [ ] merge a followup PR removing the manual pyenv bootstrapping from the `travis_ci` image.

stuhood added a commit that referenced this pull request Apr 8, 2019

Install Python 2.7 and 3.6 on Centos6 base image through Pyenv (#7064)
### Problem

We have used a python 3 interpreter in CI for a while now, using `pyenv` to install this in our Dockerfiles instead of relying on CentOS's `scl` features, which don't allow for multiple pythons at a time. Using `pyenv` to install Python 2.7 as well instead of relying on the package manager allows us to upgrade or modify the image without screwing up our Python installation.

That work began in this PR and ended up in #6981, #7352, #7418, #7483, and more, but it then led to having to duplicate code across `travis_ci` and `travis_ci_py36` Dockerfiles. Using `pyenv` to install python in our `travis_ci` images also involves a significant setup time in bootstrap phases to install our desired pythons. Installing Python in the CentOS 6 base image avoids having to install Python at all in our CI, which saves us minutes in the bootstrap phase.

### Solution

- Use Pyenv to install Python 2.7 and Python 3.6 in the `centos6` Dockerfile.
- Remove `travis_cy_py36`.
- Modify the `travis_ci` Dockerfile to bootstrap pyenv itself if not available.

### Result

We get some CI time back in the bootstrap phase.

### TODO

- [ ] merge this PR
- [ ] publish the new `centos6` image to dockerhub at `pantsbuild/centos6:latest`
- [ ] merge a followup PR removing the manual pyenv bootstrapping from the `travis_ci` image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.