diff --git a/README.md b/README.md new file mode 100644 index 0000000..c93c31d --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +### Сервер отчетов + +#### Развертывание + +1. Клонировать репозиторий + +```bash +git clone http://git.hronos.su:8080/sabron/repcofkk.git +``` + +2. Запустить compose + +```bash +docker-compose up -d +``` + +3. Создать суперпользователя + +```bash +docker compose exec web python manage.py createsuperuser +``` + +4. Заполнить переменные в админке +5. Перезапустить сервис `celery` и `gunicorn` \ No newline at end of file diff --git a/app/entrypoint.sh b/app/entrypoint.sh deleted file mode 100644 index fd8daba..0000000 --- a/app/entrypoint.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -pip install -r req.txt - -python ./manage.py migrate --no-input -python ./manage.py collectstatic --no-input - -DJANGO_SUPERUSER_PASSWORD=$SUPER_USER_PASSWORD python ./manage.py createsuperuser --username $SUPER_USER_NAME --email $SUPER_USER_EMAIL --noinput - -gunicorn ./repcofkk.wsgi:application --bind 0.0.0.0:8000 - diff --git a/docker-compose.yml b/docker-compose.yml index 3ae3396..d4f66d4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,13 +24,22 @@ services: nginx: build: ./nginx + volumes: + - static_volume:/home/app/web/static/ + - ./certbot/conf:/etc/letsencrypt + - ./certbot/www:/var/www/certbot ports: - - '80:80' + - "80:80" + - "443:443" depends_on: web: condition: service_started + certbot: + image: certbot/certbot volumes: - - static_volume:/home/app/web/static/ + - ./certbot/conf:/etc/letsencrypt + - ./certbot/www:/var/www/certbot + entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'" celery: build: ./app diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 7e430b3..9cde24b 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -3,8 +3,26 @@ upstream gunicorn { } server { - listen 80; + server_name rp.cofkk.ru; + + location /.well-known/acme-challenge/ { + root /var/www/certbot; + } + + location / { + return 301 https://$host$request_uri; + } +} + +server { + listen 443 ssl; + server_name rp.cofkk.ru; + + ssl_certificate /etc/letsencrypt/live/rp.cofkk.ru/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/rp.cofkk.ru/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; location / { proxy_pass http://gunicorn; @@ -16,5 +34,4 @@ server { location /static/ { alias /home/app/web/static/; } - } \ No newline at end of file