From 6cc694e33101a1b9ac2e9be89d6004bfa960ad61 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Fri, 26 Feb 2016 15:18:45 -0800 Subject: [PATCH] Adding tests for virtualenv usage. --- .travis.yml | 5 ++++- Dockerfile | 6 +++--- README.md | 2 +- tests/no-virtualenv/Dockerfile | 5 +++++ tests/virtualenv/Dockerfile | 28 ++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 tests/no-virtualenv/Dockerfile create mode 100644 tests/virtualenv/Dockerfile diff --git a/.travis.yml b/.travis.yml index 91985fe..4176898 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,7 @@ services: - docker script: - docker build -t google/python . -- docker build -t google/python-libraries tests/python2-libraries +- docker build tests/virtualenv +- docker build tests/no-virtualenv +# Disabled temporarily. +#- docker build -t google/python-libraries tests/python2-libraries diff --git a/Dockerfile b/Dockerfile index 38fa366..959814b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,12 +22,12 @@ ENV LANG C.UTF-8 # install virtualenv system-wide. RUN pip install --upgrade pip virtualenv -EXPOSE 8080 - RUN ln -s /home/vmagent/app /app WORKDIR /app +# Port 8080 is the port used by Google App Engine for serving HTTP traffic. +EXPOSE 8080 ENV PORT 8080 -CMD [] # The user's Dockerfile must specify an entrypoint with ENTRYPOINT or CMD. +CMD [] diff --git a/README.md b/README.md index 10c41cd..c97c6bf 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ For other docker hosts, you'll need to create a `Dockerfile` based on this image RUN virtualenv /env # Setting these environment variables are the same as running - # source /env/bin/activate + # source /env/bin/activate. ENV VIRTUAL_ENV /env ENV PATH /env/bin:$PATH diff --git a/tests/no-virtualenv/Dockerfile b/tests/no-virtualenv/Dockerfile new file mode 100644 index 0000000..68089c8 --- /dev/null +++ b/tests/no-virtualenv/Dockerfile @@ -0,0 +1,5 @@ +FROM google/python + +RUN if [ "$(which python)" != "/usr/bin/python" ]; then exit 1; fi; +RUN pip install gunicorn +RUN if [ "$(which gunicorn)" != "/usr/local/bin/gunicorn" ]; then exit 1; fi; diff --git a/tests/virtualenv/Dockerfile b/tests/virtualenv/Dockerfile new file mode 100644 index 0000000..d4effb5 --- /dev/null +++ b/tests/virtualenv/Dockerfile @@ -0,0 +1,28 @@ +FROM google/python + +ENV VIRTUAL_ENV /env +ENV PATH /env/bin:$PATH + +RUN if [ "$(which python)" != "/usr/bin/python" ]; then exit 1; fi; +RUN virtualenv /env +# All commands from this point on should use the virtualenv +RUN if [ "$(which python)" != "/env/bin/python" ]; then exit 1; fi; +RUN if [ "$(python --version 2>&1)" != "Python 2.7.9" ]; then exit 1; fi; +RUN if [ "$(which pip)" != "/env/bin/pip" ]; then exit 1; fi; +RUN pip install gunicorn flask +RUN if [ "$(which gunicorn)" != "/env/bin/gunicorn" ]; then exit 1; fi; +RUN python -c "import sys; import flask; sys.exit(0 if flask.__file__.startswith('/env') else 1)" + +# Python 3 +RUN rm -rf /env +RUN if [ "$(which python3.4)" != "/usr/bin/python3.4" ]; then exit 1; fi; +RUN virtualenv -p python3.4 /env +# All commands from this point on should use the virtualenv +RUN if [ "$(which python)" != "/env/bin/python" ]; then exit 1; fi; +RUN if [ "$(which python3)" != "/env/bin/python3" ]; then exit 1; fi; +RUN if [ "$(python --version 2>&1)" != "Python 3.4.2" ]; then exit 1; fi; +RUN if [ "$(which pip)" != "/env/bin/pip" ]; then exit 1; fi; +RUN if [ "$(which pip3)" != "/env/bin/pip3" ]; then exit 1; fi; +RUN pip install gunicorn flask +RUN if [ "$(which gunicorn)" != "/env/bin/gunicorn" ]; then exit 1; fi; +RUN python -c "import sys; import flask; sys.exit(0 if flask.__file__.startswith('/env') else 1)"