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

chore: Add default virtual environment on PATH for Docker image #1484

Merged
merged 2 commits into from
Jun 8, 2021

Conversation

matthewfeickert
Copy link
Member

@matthewfeickert matthewfeickert commented Jun 7, 2021

Description

Create a default virtual environment and place it on PATH so that it is active and used to install all libraries. Then, just COPY the virtual environment from the builder image instead of all of /usr/local/ reducing the amount of files copied to only the necessary files.

This has the added benefit of symlinking the installed python3 to the virtualenv PATH, so the equivalent of

ln -s $(command -v python3) /usr/local/venv/bin/python

This approach was recommended by Anthony Sottile in his YouTube video "how to get pip for deadsnakes / docker pythons (intermediate) anthony explains 293". Thanks Anthony!

Checklist Before Requesting Reviewer

  • Tests are passing
  • "WIP" removed from the title of the pull request
  • Selected an Assignee for the PR to be responsible for the log summary

Before Merging

For the PR Assignees:

  • Summarize commit messages into a comprehensive review of the PR
* Add a venv virtual environment to PATH
   - Adding venv also symlinks the python doing the installing to the virtual environment's python
      -  e.g. `ls -l $(which python)` shows `/usr/local/venv/bin/python -> /usr/local/bin/python`
   - Thanks to Anthony Sottile for recommending this approach
   - c.f. https://youtu.be/2Hg5-Hrsa6w
   - c.f. https://github.com/pyhf/cuda-images/pull/3
* Update hadolint GitHub Action to hadolint/hadolint-action@v1.5.0

@matthewfeickert matthewfeickert added CI CI systems, GitHub Actions Docker Involving Docker images or builds labels Jun 7, 2021
@matthewfeickert matthewfeickert self-assigned this Jun 7, 2021
@codecov
Copy link

codecov bot commented Jun 7, 2021

Codecov Report

Merging #1484 (168ec72) into master (6d3ff05) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1484   +/-   ##
=======================================
  Coverage   97.65%   97.65%           
=======================================
  Files          63       63           
  Lines        4006     4006           
  Branches      565      565           
=======================================
  Hits         3912     3912           
  Misses         55       55           
  Partials       39       39           
Flag Coverage Δ
contrib 25.51% <ø> (ø)
unittests 97.42% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d3ff05...168ec72. Read the comment docs.

@matthewfeickert
Copy link
Member Author

@lukasheinrich @kratsg I used this approach first in pyhf/cuda-images#3 and it works well there. 👍

@matthewfeickert matthewfeickert added the chore Other changes that don't modify src or test files label Jun 8, 2021
@matthewfeickert matthewfeickert merged commit e8a182d into master Jun 8, 2021
@matthewfeickert matthewfeickert deleted the docker/use-default-venv branch June 8, 2021 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Other changes that don't modify src or test files CI CI systems, GitHub Actions Docker Involving Docker images or builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant