From 3aaf11ecf534c5aef293526e0addec19216a4a8b Mon Sep 17 00:00:00 2001 From: Artur Pragacz Date: Mon, 18 May 2020 12:49:05 +0200 Subject: [PATCH] (SIO-2356) Fix supervisor.conf template and upgrading info. Add hooks for Docker Hub. Change-Id: I55b1b3da935f4b061642d4188b289115219999cc --- .dockerignore | 51 +++++++++++++++------ .gitignore | 29 ++++++------ UPGRADING.rst | 49 +++++++++++++++----- docker-compose-selenium.yml | 4 +- hooks/build | 1 + oioioi/default_settings.py | 6 +-- oioioi/deployment/settings.py.template | 2 +- oioioi/deployment/supervisord.conf.template | 4 +- 8 files changed, 100 insertions(+), 46 deletions(-) create mode 100755 hooks/build diff --git a/.dockerignore b/.dockerignore index 59ab821be..a9b798626 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,14 +1,39 @@ -Dockerfile* -docker* -.dockerignore -.git -.github -.idea -*.swp -venv -logs -deployment -extra +# use syntax common to .gitignore and .dockerignore + +# /rst/source/sections/modules.rst +/build/ +/dist/ +# /test_report.html +# /test_report/ +# /test_log.txt +# /test_screenshots.tar.gz +/.coverage +/cover/ +**/*.egg +**/*.egg-info +**/*.pid +**/.DS_Store +**/*.pyc +**/__pycache__/ +**/*.kdev* +**/*~ +/.tox/ +/.pytest_cache/ +/.eggs/ +**/*.swp +/deployment/ +/venv*/ +/.idea/ + +# docker specific + +/Dockerfile* +/docker* +/.dockerignore +/.git +/.gitignore +/.github +/extra/ /test* -*.rst -/rst +/*.rst +/rst/ diff --git a/.gitignore b/.gitignore index e0a5e084a..5b45c45f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,26 @@ +# use syntax common to .gitignore and .dockerignore + /rst/source/sections/modules.rst /build/ /dist/ /test_report.html /test_report/ -/.coverage -/cover/ -*.egg -*.egg-info -*.pid -.DS_Store -/.vagrant/ -*.pyc -*.kdev* -*~ -vagrant.yml /test_log.txt /test_screenshots.tar.gz -/logs/ +/.coverage +/cover/ +**/*.egg +**/*.egg-info +**/*.pid +**/.DS_Store +**/*.pyc +**/__pycache__/ +**/*.kdev* +**/*~ /.tox/ /.pytest_cache/ /.eggs/ -*.swp +**/*.swp /deployment/ -/venv/ +/venv*/ +/.idea/ diff --git a/UPGRADING.rst b/UPGRADING.rst index 5415cd967..cd1cfc2b8 100644 --- a/UPGRADING.rst +++ b/UPGRADING.rst @@ -871,16 +871,43 @@ List of changes since the *CONFIG_VERSION* numbering was introduced: To make sure that your typical production setup (UWSGI + reverse proxy) keeps working, set this to 'uwsgi'.:: - @@ -28,12 +27,20 @@ SITE_NAME = 'OIOIOI' - # including but not limited to the mail notifications. - PUBLIC_ROOT_URL = 'http://localhost' - - -# Run uwsgi daemon. Shall be True, False or 'auto'. - -# 'auto' means daemon will be run iff DEBUG is disabled. - -UWSGI_ENABLED = 'auto' + --- a/oioioi/deployment/settings.py.template + +++ b/oioioi/deployment/settings.py.template + @@ -34,0 +38,6 @@ +# The server to be run. Options are: - +# django - django's http server - +# uwsgi - uwsgi daemon - +# uwsgi-http - uwsgi deamon with builtin http server + +# 'django' - django's http server + +# 'uwsgi' - uwsgi daemon + +# 'uwsgi-http' - uwsgi deamon with built-in http server +# None - nothing will be run - +SERVER = None + +SERVER = 'django' + + * Appropriate changes were also made to the supervisor configuration.:: + + --- a/oioioi/deployment/supervisord.conf.template + +++ b/oioioi/deployment/supervisord.conf.template + @@ -7,17 +7,19 @@ directory={{ PROJECT_DIR }} + identifier=oioioi-supervisor + + [program:uwsgi] + -{% if settings.UWSGI_USE_GEVENT %} + -command=uwsgi -s {{ PROJECT_DIR }}/uwsgi.sock --umask=000 --loop=gevent --async=50 --processes=10 -M --max-requests=5000 --disable-logging --need-app --enable-threads --socket-timeout=30 --wsgi-file={{ PROJECT_DIR }}/wsgi.py + -{% else %} + -command=uwsgi -s {{ PROJECT_DIR }}/uwsgi.sock --umask=000 --processes=10 -M --max-requests=5000 --disable-logging --need-app --enable-threads --socket-timeout=30 --wsgi-file={{ PROJECT_DIR }}/wsgi.py + -{% endif %} + +command=uwsgi {% if settings.SERVER == 'uwsgi-http' %}--http :8000 --static-map {{ settings.STATIC_URL }}={{ settings.STATIC_ROOT }} {% else %}-s {{ PROJECT_DIR }}/uwsgi.sock {% endif %}--umask=000 {% if settings.UWSGI_USE_GEVENT %}--loop=gevent --async=50 {% endif %}--processes=10 -M --max-requests=5000 --disable-logging --need-app --enable-threads --socket-timeout=30 --wsgi-file={{ PROJECT_DIR }}/wsgi.py + stopsignal=INT + startretries=0 + redirect_stderr=false + stdout_logfile={{ PROJECT_DIR }}/logs/uwsgi.log + stderr_logfile={{ PROJECT_DIR }}/logs/uwsgi-err.log + -{% if settings.UWSGI_ENABLED == False %}exclude=true{% elif settings.UWSGI_ENABLED == 'auto' and settings.DEBUG %}exclude=true{% endif %} + +{% if settings.SERVER|slice:":5" != 'uwsgi' %}exclude=true{% endif %} + + + +[program:django-http] + +command={{ PYTHON }} {{ PROJECT_DIR }}//manage.py runserver 0.0.0.0:8000 + +stdout_logfile={{ PROJECT_DIR }}/logs/runserver/out.log + +stderr_logfile={{ PROJECT_DIR }}/logs/runserver/err.log + +{% if settings.SERVER != 'django' %}exclude=true{% endif %} + + [program:rankingsd] + command={{ PYTHON }} {{ PROJECT_DIR }}/manage.py rankingsd diff --git a/docker-compose-selenium.yml b/docker-compose-selenium.yml index ea502a7b1..5d2d780d7 100644 --- a/docker-compose-selenium.yml +++ b/docker-compose-selenium.yml @@ -9,7 +9,7 @@ services: POSTGRES_DB: "oioioi" stop_grace_period: 1m web: - image: sio2project/oioioi + image: sio2project/oioioi-selenium command: ["/sio2/oioioi/selenium_init.sh"] build: context: . @@ -25,7 +25,7 @@ services: - db - broker worker: - image: sio2project/oioioi + image: sio2project/oioioi-selenium command: ["/sio2/oioioi/worker_init.sh"] cap_add: - ALL diff --git a/hooks/build b/hooks/build new file mode 100755 index 000000000..2d1fffb7d --- /dev/null +++ b/hooks/build @@ -0,0 +1 @@ +docker build --add-host=web:127.0.0.1 -f $DOCKERFILE_PATH -t $IMAGE_NAME . diff --git a/oioioi/default_settings.py b/oioioi/default_settings.py index 4aef93383..c87d57d63 100755 --- a/oioioi/default_settings.py +++ b/oioioi/default_settings.py @@ -24,9 +24,9 @@ PUBLIC_ROOT_URL = 'http://localhost' # The server to be run. Options are: -# django - django's http server -# uwsgi - uwsgi daemon -# uwsgi-http - uwsgi deamon with builtin http server +# 'django' - django's http server +# 'uwsgi' - uwsgi daemon +# 'uwsgi-http' - uwsgi deamon with built-in http server # None - nothing will be run SERVER = None diff --git a/oioioi/deployment/settings.py.template b/oioioi/deployment/settings.py.template index 86f8c5290..c1514d535 100755 --- a/oioioi/deployment/settings.py.template +++ b/oioioi/deployment/settings.py.template @@ -38,7 +38,7 @@ ALLOWED_HOSTS = [] # The server to be run. Options are: # 'django' - django's http server # 'uwsgi' - uwsgi daemon -# 'uwsgi-http' - uwsgi deamon with builtin http server +# 'uwsgi-http' - uwsgi deamon with built-in http server # None - nothing will be run SERVER = 'django' diff --git a/oioioi/deployment/supervisord.conf.template b/oioioi/deployment/supervisord.conf.template index 60e87f954..74e9a2bbf 100644 --- a/oioioi/deployment/supervisord.conf.template +++ b/oioioi/deployment/supervisord.conf.template @@ -17,8 +17,8 @@ stderr_logfile={{ PROJECT_DIR }}/logs/uwsgi-err.log [program:django-http] command={{ PYTHON }} {{ PROJECT_DIR }}//manage.py runserver 0.0.0.0:8000 -stdout_logfile={{ PROJECT_DIR }}/logs/runserver/out.log -stderr_logfile={{ PROJECT_DIR }}/logs/runserver/err.log +stdout_logfile={{ PROJECT_DIR }}/logs/runserver.log +stderr_logfile={{ PROJECT_DIR }}/logs/runserver-err.log {% if settings.SERVER != 'django' %}exclude=true{% endif %} [program:rankingsd]