Skip to content

Commit

Permalink
Adding tests for virtualenv usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott committed Mar 1, 2016
1 parent f44dc6a commit 6cc694e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions tests/no-virtualenv/Dockerfile
Original file line number Diff line number Diff line change
@@ -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;
28 changes: 28 additions & 0 deletions tests/virtualenv/Dockerfile
Original file line number Diff line number Diff line change
@@ -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)"

0 comments on commit 6cc694e

Please sign in to comment.