From c5d84bfeab6d54db754626c0913ecd4e0ce5c274 Mon Sep 17 00:00:00 2001 From: Abhilash Raj Date: Sun, 20 Jan 2019 16:39:11 -0800 Subject: [PATCH] Use alpine images instead of Python. (#290) * Use alpine images instead of Python. * Minor fix to use python3 -m pip * Fix settings for paintstore. --- core/Dockerfile | 11 +++++----- core/Dockerfile.dev | 13 ++++++----- core/docker-entrypoint.sh | 2 +- web/Dockerfile | 3 +-- web/Dockerfile.dev | 44 ++++++++++++++++++++----------------- web/mailman-web/settings.py | 15 ++++++++++--- 6 files changed, 51 insertions(+), 37 deletions(-) diff --git a/core/Dockerfile b/core/Dockerfile index d163229..e66cfe5 100644 --- a/core/Dockerfile +++ b/core/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.6-alpine +FROM alpine:3.8 MAINTAINER Abhilash Raj @@ -7,10 +7,11 @@ COPY docker-entrypoint.sh /usr/local/bin/ #Install all required packages, add user for executing mailman and set execution rights for startup script RUN apk update \ - && apk add --virtual build-deps gcc python3-dev musl-dev postgresql-dev libffi-dev \ - && apk add bash su-exec postgresql-client mysql-client curl \ - && pip install -U pip \ - && pip install psycopg2 \ + && apk add --virtual build-deps gcc python3-dev musl-dev postgresql-dev \ + libffi-dev \ + && apk add --no-cache bash su-exec postgresql-client mysql-client curl python py3-setuptools \ + && python3 -m pip install -U pip \ + && python3 -m pip install psycopg2 \ mailman==3.2 \ mailman-hyperkitty==1.1.0 \ pymysql \ diff --git a/core/Dockerfile.dev b/core/Dockerfile.dev index 08045bc..970e581 100644 --- a/core/Dockerfile.dev +++ b/core/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM python:3.6-alpine +FROM alpine:3.8 MAINTAINER Abhilash Raj @@ -13,11 +13,12 @@ ARG MM3_HK_REF #Install all required packages, add user for executing mailman and set execution #rights for startup script RUN apk update \ - && apk add --virtual build-deps gcc python3-dev musl-dev postgresql-dev git libffi-dev \ - && apk add bash su-exec postgresql-client mysql-client curl \ - && pip install -U psycopg2 pymysql \ - git+https://gitlab.com/mailman/mailman@${CORE_REF} \ - git+https://gitlab.com/mailman/mailman-hyperkitty@${MM3_HK_REF} \ + && apk add --no-cache --virtual build-deps gcc python3-dev musl-dev \ + postgresql-dev git libffi-dev \ + && apk add --no-cache bash su-exec postgresql-client mysql-client curl python3 py3-setuptools \ + && python3 -m pip install -U psycopg2 pymysql \ + git+https://gitlab.com/mailman/mailman@${CORE_REF} \ + git+https://gitlab.com/mailman/mailman-hyperkitty@${MM3_HK_REF} \ && apk del build-deps \ && adduser -S mailman diff --git a/core/docker-entrypoint.sh b/core/docker-entrypoint.sh index 870a8ec..e976907 100755 --- a/core/docker-entrypoint.sh +++ b/core/docker-entrypoint.sh @@ -4,7 +4,7 @@ set -e function wait_for_postgres () { # Check if the postgres database is up and accepting connections before # moving forward. - # TODO: Use python's psycopg2 module to do this in python instead of + # TODO: Use python3's psycopg2 module to do this in python3 instead of # installing postgres-client in the image. until psql $DATABASE_URL -c '\l'; do >&2 echo "Postgres is unavailable - sleeping" diff --git a/web/Dockerfile b/web/Dockerfile index 1071f2c..a8570fd 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -44,6 +44,5 @@ EXPOSE 8000 8080 STOPSIGNAL SIGINT ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["uwsgi", "--ini", "/opt/mailman-web/uwsgi.ini"] -ENV PYTHONPATH=/usr/lib/python3.6/site-packages +CMD ["uwsgi", "--ini", "/opt/mailman-web/uwsgi.ini"] diff --git a/web/Dockerfile.dev b/web/Dockerfile.dev index 73ed759..07d2074 100644 --- a/web/Dockerfile.dev +++ b/web/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM python:3.6-alpine3.7 +FROM alpine:3.8 MAINTAINER Abhilash Raj @@ -16,25 +16,29 @@ ARG CLIENT_REF # executing apps, change ownership for uwsgi+django files and set execution # rights for management script RUN set -ex \ - && apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers git \ - postgresql-dev mariadb-dev \ - && apk add --no-cache --virtual .mailman-rundeps bash sassc \ - postgresql-client mysql-client py-mysqldb curl mailcap \ - && pip install -U git+https://gitlab.com/mailman/mailmanclient@${CLIENT_REF} \ - git+https://gitlab.com/mailman/postorius@${POSTORIUS_REF} \ - git+https://gitlab.com/mailman/hyperkitty@${HYPERKITTY_REF} \ - whoosh \ - uwsgi \ - psycopg2 \ - dj-database-url \ - mysqlclient \ - && pip install -U django>=1.11\ - && pip install -U git+https://gitlab.com/mailman/django-mailman3@${DJ_MM3_REF} \ - && apk del .build-deps \ - && addgroup -S mailman \ - && adduser -S -G mailman mailman \ - && chown -R mailman /opt/mailman-web/ \ - && chmod u+x /opt/mailman-web/manage.py + && apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers git \ + postgresql-dev mariadb-dev python3-dev \ + && apk add --no-cache --virtual .mailman-rundeps bash sassc \ + python3 py3-setuptools postgresql-client mysql-client py-mysqldb\ + curl mailcap xapian-core xapian-bindings-python3 \ + && python3 -m pip install -U \ + git+https://gitlab.com/mailman/mailmanclient@${CLIENT_REF} \ + git+https://gitlab.com/mailman/postorius@${POSTORIUS_REF} \ + git+https://gitlab.com/mailman/hyperkitty@${HYPERKITTY_REF} \ + whoosh \ + uwsgi \ + psycopg2 \ + dj-database-url \ + mysqlclient \ + xapian-haystack \ + && python3 -m pip install -U django>=1.11\ + && python3 -m pip install -U \ + git+https://gitlab.com/mailman/django-mailman3@${DJ_MM3_REF} \ + && apk del .build-deps \ + && addgroup -S mailman \ + && adduser -S -G mailman mailman \ + && chown -R mailman /opt/mailman-web/ \ + && chmod u+x /opt/mailman-web/manage.py WORKDIR /opt/mailman-web diff --git a/web/mailman-web/settings.py b/web/mailman-web/settings.py index d7cc6e3..80c24d4 100644 --- a/web/mailman-web/settings.py +++ b/web/mailman-web/settings.py @@ -65,7 +65,7 @@ MAILMAN_ARCHIVER_FROM = os.environ.get('MAILMAN_HOST_IP', '172.19.199.2') # Application definition -INSTALLED_APPS = ( +INSTALLED_APPS = [ 'hyperkitty', 'postorius', 'django_mailman3', @@ -81,7 +81,6 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'rest_framework', 'django_gravatar', - 'paintstore', 'compressor', 'haystack', 'django_extensions', @@ -94,7 +93,17 @@ INSTALLED_APPS = ( 'allauth.socialaccount.providers.github', 'allauth.socialaccount.providers.gitlab', 'allauth.socialaccount.providers.google', -) +] + +# Optionally include paintstore, if it was installed with Hyperkitty. +# TODO: Remove this after a new version of Hyperkitty is released and +# neither the stable nor the rolling version needs it. +try: + import paintstore + INSTALLED_APPS.append('paintstore') +except ImportError: + pass + _MIDDLEWARE = ( 'django.contrib.sessions.middleware.SessionMiddleware',