Dockerflow and Dockerfile improvements

- fix circle-ci container testing
- add WORKDIR to Dockerfile to making working with the container
  a bit more convenient
- add conf/run.sh as a better ENTRYPOINT since the
  container is multi-use
- refactor Dockerfile ENTRYPOINT/CMD to use conf/run.sh
  - containers works more like a program now
- refactor test command line, now doesn't fail on linting test data
This commit is contained in:
Benson Wong 2016-03-14 14:44:10 -07:00
Родитель fe109e83e5
Коммит f7d1656972
5 изменённых файлов: 35 добавлений и 8 удалений

Просмотреть файл

@ -8,15 +8,22 @@ MAINTAINER https://mail.mozilla.org/listinfo/testpilot-dev
RUN groupadd --gid 10001 app && \
useradd --uid 10001 --gid 10001 --shell /usr/sbin/nologin app
WORKDIR /app
# Install libmemcached-dev, whose C libraries are required by pylibmc.
RUN apt-get -qq update && apt-get -qq install -y libmemcached-dev=1.0.18-4
RUN apt-get -qq update && \
apt-get -qq install -y libmemcached-dev=1.0.18-4
COPY ./requirements.txt /app/requirements.txt
RUN pip install --upgrade --no-cache-dir -r /app/requirements.txt
COPY . /app
ENV PYTHONPATH $PYTHONPATH:/app
EXPOSE 8000
# Run the web service by default.
ENTRYPOINT ["/app/conf/run.sh"]
CMD ["web"]
COPY . /app
USER app
EXPOSE 8000
ENTRYPOINT ["/app/conf/web.sh"]

Просмотреть файл

@ -29,8 +29,7 @@ dependencies:
# Run flake8 and the Python test suite via nose.
test:
override:
- docker run -d app:build sh -c 'flake8 . --exclude=app/src && nosetests --exclude-dir=app/src'
- docker run app:build test
# Tag and push the container to Docker Hub.
deployment:

21
conf/run.sh Executable file
Просмотреть файл

@ -0,0 +1,21 @@
#!/bin/bash
cd $(dirname $0)
case "$1" in
web)
echo "Starting Web Server"
exec ./web.sh
;;
worker)
echo "Starting Celery Worker"
exec ./worker.sh
;;
test)
echo "Running Tests"
cd ..
flake8 . --exclude=./recommendation/views/data/dummy.py && nosetests
;;
*)
echo "Usage: $0 {web|worker|test}"
exit 1
esac

Просмотреть файл

@ -1,3 +1,3 @@
#!/usr/bin/env bash
uwsgi --http :${PORT:-8000} --wsgi-file /app/recommendation/wsgi.py --master
exec uwsgi --http :${PORT:-8000} --wsgi-file /app/recommendation/wsgi.py --master

Просмотреть файл

@ -1,3 +1,3 @@
#!/usr/bin/env bash
celery worker --app=recommendation
exec celery worker --app=recommendation