Browse Source

Ensure that server is started correctly in Docker

Also: ignore files generated during application run which enables a
better development experience in Docker with source mounts like
`docker run -p 8080:80 -v $PWD:/doccano -it doccano`.
pull/68/head
Clemens Wolff 5 years ago
parent
commit
0b1f464c74
4 changed files with 19 additions and 2 deletions
  1. 2
      .dockerignore
  2. 5
      .gitignore
  3. 6
      Dockerfile
  4. 8
      tools/run.sh

2
.dockerignore

@ -1,5 +1,7 @@
* *
!app/ !app/
app/staticfiles/
app/db.sqlite3
!data/ !data/
!tests/ !tests/
!tools/ !tools/

5
.gitignore

@ -195,4 +195,7 @@ pip-selfcheck.json
/data/sparql/* /data/sparql/*
# ignore db to avoid merge conflicts # ignore db to avoid merge conflicts
*.sqlite3
*.sqlite3
# ignore django generated static files
app/staticfiles/

6
Dockerfile

@ -11,5 +11,9 @@ WORKDIR /doccano
ENV DEBUG="True" ENV DEBUG="True"
ENV SECRET_KEY="change-me-in-production" ENV SECRET_KEY="change-me-in-production"
ENV BIND="0.0.0.0:80"
ENV WORKERS="2"
CMD ["gunicorn", "--bind=0.0.0.0:80", "--workers=2", "--pythonpath=app", "app.wsgi"]
EXPOSE 80
CMD ["/doccano/tools/run.sh"]

8
tools/run.sh

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -o errexit
if [[ ! -d "app/staticfiles" ]]; then python app/manage.py collectstatic --noinput; fi
python app/manage.py migrate
gunicorn --bind="${BIND:-127.0.0.1:8000}" --workers="${WORKERS:-1}" --pythonpath=app app.wsgi
Loading…
Cancel
Save