Browse Source

Support async upload in docker-compose.prod.yml

pull/1310/head
Hironsan 3 years ago
parent
commit
64f9268570
5 changed files with 78 additions and 1 deletions
  1. 2
      app/Dockerfile.prod
  2. 31
      docker-compose.prod.yml
  3. 5
      nginx/nginx.conf
  4. 12
      tools/prod-celery.sh
  5. 29
      tools/prod-django.sh

2
app/Dockerfile.prod

@ -26,4 +26,4 @@ RUN apt-get update \
COPY tools/ /opt/bin/
ENTRYPOINT [ "/opt/bin/run.sh" ]
ENTRYPOINT [ "/opt/bin/prod-django.sh" ]

31
docker-compose.prod.yml

@ -7,10 +7,12 @@ services:
dockerfile: app/Dockerfile.prod
volumes:
- static_volume:/app/staticfiles
- media:/app/media
environment:
ADMIN_USERNAME: "admin"
ADMIN_PASSWORD: "password"
ADMIN_EMAIL: "admin@example.com"
CELERY_BROKER_URL: "amqp://doccano:doccano@rabbitmq"
DATABASE_URL: "postgres://doccano:doccano@postgres:5432/doccano?sslmode=disable"
ALLOW_SIGNUP: "False"
DEBUG: "False"
@ -20,6 +22,33 @@ services:
- network-backend
- network-frontend
celery:
build:
context: .
dockerfile: app/Dockerfile.prod
volumes:
- media:/app/media
entrypoint: ["/opt/bin/prod-celery.sh"]
environment:
PYTHONUNBUFFERED: "1"
CELERY_BROKER_URL: "amqp://doccano:doccano@rabbitmq"
DATABASE_URL: "postgres://doccano:doccano@postgres:5432/doccano?sslmode=disable"
depends_on:
- postgres
- rabbitmq
networks:
- network-backend
rabbitmq:
image: rabbitmq:3.8
environment:
RABBITMQ_DEFAULT_USER: "doccano"
RABBITMQ_DEFAULT_PASS: "doccano"
ports:
- 5672:5672
networks:
- network-backend
nginx:
build:
context: .
@ -29,6 +58,7 @@ services:
GOOGLE_TRACKING_ID: ""
volumes:
- static_volume:/static
- media:/media
ports:
- 80:80
depends_on:
@ -50,6 +80,7 @@ services:
volumes:
postgres_data:
static_volume:
media:
networks:
network-backend:

5
nginx/nginx.conf

@ -47,6 +47,11 @@ server {
autoindex on;
alias /static/;
}
location /media/ {
autoindex on;
alias /media/;
}
}
server_tokens off;

12
tools/prod-celery.sh

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -o errexit
cd /app
(
echo "Waiting for database"
python manage.py wait_for_db
echo "Starting celery"
"celery" --app=app worker --loglevel=info --pool=solo
)

29
tools/prod-django.sh

@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -o errexit
echo "Making staticfiles"
static_dir=staticfiles
mkdir -p client/dist/static
if [[ ! -d $static_dir ]] || [[ -z $(ls -A $static_dir) ]]; then
echo "Executing collectstatic"
python manage.py collectstatic --noinput;
fi
echo "Initializing database"
python manage.py wait_for_db
python manage.py migrate
python manage.py create_roles
echo "Creating admin"
if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMIN_EMAIL}" ]]; then
python manage.py create_admin \
--username "${ADMIN_USERNAME}" \
--password "${ADMIN_PASSWORD}" \
--email "${ADMIN_EMAIL}" \
--noinput \
|| true
fi
echo "Starting django"
gunicorn --bind="0.0.0.0:${PORT:-8000}" --workers="${WORKERS:-4}" app.wsgi --timeout 300
Loading…
Cancel
Save