From 7bc5bf5dc46ded22b0de3e98edcc8cdebb2706f0 Mon Sep 17 00:00:00 2001 From: Abhilash Raj Date: Sun, 28 May 2017 14:20:39 -0700 Subject: [PATCH] Use a config file for uwsgi. --- docker-compose.yaml | 4 ---- web/Dockerfile | 26 +++++++++++--------------- web/assets/run.sh | 21 +++------------------ web/mailman-web/uwsgi.ini | 10 ++++++++++ 4 files changed, 24 insertions(+), 37 deletions(-) create mode 100644 web/mailman-web/uwsgi.ini diff --git a/docker-compose.yaml b/docker-compose.yaml index 61a87d7..034078f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -32,10 +32,6 @@ services: volumes: - /opt/mailman/web:/opt/mailman-web-data environment: - - UWSGI_WSGI_FILE=wsgi.py - - UWSGI_HTTP=:8000 - - UWSGI_WORKERS=2 - - UWSGI_THREADS=4 - DATABASE_URL=postgres://mailman:mailmanpass@database/mailmandb - HYPERKITTY_API_KEY=someapikey networks: diff --git a/web/Dockerfile b/web/Dockerfile index 1951c0a..be7a532 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -10,20 +10,16 @@ RUN apt-get update \ postgresql-client \ && rm -rf /var/lib/apt/lists/* -RUN wget -O mailmanclient.zip https://gitlab.com/mailman/mailmanclient/repository/archive.zip?ref=master \ - && wget -O postorius.zip https://gitlab.com/mailman/postorius/repository/archive.zip?ref=master \ - && wget -O django-mailman3.zip https://gitlab.com/mailman/django-mailman3/repository/archive.zip?ref=master \ - && wget -O hyperkitty.zip https://gitlab.com/mailman/hyperkitty/repository/archive.zip?ref=master \ - && python -m pip install -U mailmanclient.zip \ - postorius.zip \ - hyperkitty.zip \ - whoosh \ - uwsgi \ - psycopg2 \ - dj-database-url \ - pymysql \ - && python -m pip install -U django-mailman3.zip \ - && rm mailmanclient.zip postorius.zip hyperkitty.zip django-mailman3.zip +RUN python -m pip install -U mailmanclient==3.1.0 \ + postorius==1.1.0 \ + hyperkitty==1.1.0 \ + django-mailman3==1.1.0 \ + whoosh \ + uwsgi \ + psycopg2 \ + dj-database-url \ + pymysql \ + && python -m pip install -U django==1.10 ADD mailman-web /opt/mailman-web @@ -35,4 +31,4 @@ EXPOSE 8000 ENTRYPOINT ["/opt/run.sh"] -CMD ["uwsgi", "--http-auto-chunked","--http-keepalive"] +CMD ["uwsgi", "--ini", "/opt/mailman-web/uwsgi.ini"] diff --git a/web/assets/run.sh b/web/assets/run.sh index b34ddc9..dafb162 100755 --- a/web/assets/run.sh +++ b/web/assets/run.sh @@ -49,8 +49,9 @@ if [[ ! -v DATABASE_URL ]]; then echo "DATABASE_URL is not defined. Using sqlite database..." export DATABASE_URL=sqlite://mailmanweb.db export DATABASE_TYPE='sqlite' -else - export DATABASE_TYPE='postgres' +fi + +if [[ "$DATABASE_TYPE" = 'postgres' ]]; then wait_for_postgres fi @@ -88,20 +89,4 @@ python manage.py collectstatic --noinput # this command will upgrade the database. python manage.py migrate - -# Log to the default location /opt/mailman-web-data/logs/uwsgi.log if the -# logging variable is not set. -if [[ ! -v UWSGI_LOGTO ]]; then - echo "No UWSGI_LOGTO defined, logging uwsgi to /opt/mailman-web-data/logs/uwsgi.log ..." - export UWSGI_LOGTO='/opt/mailman-web-data/logs/uwsgi.log' - touch "$UWSGI_LOGTO" -fi - -if [[ ! -v UWSGI_WSGI_FILE ]]; then - export UWSGI_WSGI_FILE="wsgi.py" - export UWSGI_HTTP=:8000 - export UWSGI_WORKERS=2 - export UWSGI_THREADS=4 -fi - exec $@ diff --git a/web/mailman-web/uwsgi.ini b/web/mailman-web/uwsgi.ini new file mode 100644 index 0000000..659d978 --- /dev/null +++ b/web/mailman-web/uwsgi.ini @@ -0,0 +1,10 @@ +[uwsgi] +http = :8000 +chdir = /opt/mailman-web +wsgi-file = wsgi.py +process = 2 +threads = 2 +uid = 1000 +gid = 1000 +req-log = file:/opt/mailman-web-data/uwsgi.log +error-log = file:/opt/mailman-web-data/uwsgi-error.log