Created
September 7, 2018 13:55
-
-
Save saabeilin/f5e75389bfbf49c9269cb799728c6837 to your computer and use it in GitHub Desktop.
Pull Docker image, setup pyenv for same python version, create virtualenv, install dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e -x | |
BASEIMAGE=`cat Dockerfile | grep ^FROM | cut -d " " -f 2` | |
docker pull $BASEIMAGE | |
PYTHON_DOCKER_VERSION=`docker run --rm $BASEIMAGE python --version | grep ^Python | cut -d " " -f 2` | |
if [ -e .python-version ]; | |
then | |
PYTHON_LOCAL_VERSION=`cat .python-version` | |
if [[ ! $PYTHON_DOCKER_VERSION == $PYTHON_LOCAL_VERSION ]]; then | |
echo "Python versions do not match: local is $PYTHON_LOCAL_VERSION, docker is $PYTHON_DOCKER_VERSION" | |
exit -1 | |
fi | |
fi | |
pyenv versions --bare | grep $PYTHON_DOCKER_VERSION || pyenv install $PYTHON_DOCKER_VERSION | |
pyenv local $PYTHON_DOCKER_VERSION | |
virtualenv .venv/ | |
source .venv/bin/activate | |
pip install -r requirements-dev.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment