diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index ee8ca2be..00000000 --- a/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM python:3.6 - -ADD . /app -WORKDIR /app - -RUN pip install tox diff --git a/Makefile b/Makefile index ad64412f..6fc1c8fa 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ test: find . -name "*.pyc" -delete - docker build -t sanic/test-image . + docker build -t sanic/test-image -f docker/Dockerfile . docker run -t sanic/test-image tox diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..dc7832ff --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,28 @@ +FROM alpine:3.7 + +RUN apk add --no-cache --update \ + curl \ + bash \ + build-base \ + ca-certificates \ + git \ + bzip2-dev \ + linux-headers \ + ncurses-dev \ + openssl \ + openssl-dev \ + readline-dev \ + sqlite-dev + +RUN update-ca-certificates +RUN rm -rf /var/cache/apk/* + +ENV PYENV_ROOT="/root/.pyenv" +ENV PATH="$PYENV_ROOT/bin:$PATH" + +ADD . /app +WORKDIR /app + +RUN /app/docker/bin/install_python.sh 3.5.4 3.6.4 + +ENTRYPOINT ["./docker/bin/entrypoint.sh"] diff --git a/docker/bin/entrypoint.sh b/docker/bin/entrypoint.sh new file mode 100755 index 00000000..762d2155 --- /dev/null +++ b/docker/bin/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +eval "$(pyenv init -)" +eval "$(pyenv virtualenv-init -)" +source /root/.pyenv/completions/pyenv.bash + +pip install tox + +exec $@ + diff --git a/docker/bin/install_python.sh b/docker/bin/install_python.sh new file mode 100755 index 00000000..e7c4aa1f --- /dev/null +++ b/docker/bin/install_python.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +export CFLAGS='-O2' +export EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" + +curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash +eval "$(pyenv init -)" + +for ver in $@ +do + pyenv install $ver +done + +pyenv global $@ +pip install --upgrade pip +pyenv rehash