Skip to content

Instantly share code, notes, and snippets.

@saabeilin
Created September 7, 2018 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saabeilin/f5e75389bfbf49c9269cb799728c6837 to your computer and use it in GitHub Desktop.
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
#!/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