Merge branch 'main' into fix_sqlite-url

This commit is contained in:
Abhilash Raj
2024-06-08 06:29:18 +05:30
committed by GitHub
27 changed files with 262 additions and 147 deletions

View File

@@ -1,34 +1,36 @@
# syntax = docker/dockerfile:1.3
FROM alpine:3.12
# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/
FROM alpine:3.20.0
# Install packages and dependencies for postorius and hyperkitty Add user for
# executing apps, change ownership for uwsgi+django files and set execution
# rights for management script
RUN --mount=type=cache,target=/root/.cache \
set -ex \
&& apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers \
&& apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers libldap \
postgresql-dev mariadb-dev mariadb-connector-c python3-dev libffi-dev openldap-dev cargo rust \
&& apk add --no-cache --virtual .mailman-rundeps bash sassc \
&& apk add --no-cache --virtual .mailman-rundeps bash sassc tzdata \
postgresql-client mysql-client py3-mysqlclient curl mailcap gettext \
python3 py3-pip libffi libuuid pcre-dev py-cryptography \
&& python3 -m pip install -U 'Django<3.2' pip setuptools wheel \
&& python3 -m pip install postorius==1.3.6 \
&& python3 -m pip install --break-system-packages -U 'Django<4.3' pip setuptools wheel \
&& python3 -m pip install --break-system-packages postorius==1.3.10 \
uwsgi \
'psycopg2<2.9' \
psycopg2 \
dj-database-url \
mysqlclient \
typing \
django-auth-ldap \
python-memcached \
tzdata \
&& apk del .build-deps \
&& addgroup -S mailman \
&& adduser -S -G mailman mailman \
&& chown -R mailman /opt/mailman-web/ \
&& adduser -S -G mailman mailman
# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/
RUN chown -R mailman /opt/mailman-web/ \
&& chmod u+x /opt/mailman-web/manage.py
WORKDIR /opt/mailman-web

View File

@@ -1,10 +1,5 @@
# syntax = docker/dockerfile:1.3
FROM alpine:3.12
# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/
FROM alpine:3.20.0
ARG POSTORIUS_REF
ARG DJ_MM3_REF
@@ -15,28 +10,34 @@ ARG CLIENT_REF
# rights for management script
RUN --mount=type=cache,target=/root/.cache \
set -ex \
&& apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers \
&& apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers libldap \
postgresql-dev mariadb-dev mariadb-connector-c python3-dev libffi-dev git cargo rust \
&& apk add --no-cache --virtual .mailman-rundeps bash sassc \
&& apk add --no-cache --virtual .mailman-rundeps bash sassc tzdata \
postgresql-client mysql-client py3-mysqlclient curl mailcap \
python3 py3-pip libffi gettext py-cryptography \
&& python3 -m pip install -U pip setuptools wheel \
&& python3 -m pip install -U \
&& python3 -m pip install --break-system-packages -U pip setuptools wheel \
&& python3 -m pip install --break-system-packages -U \
git+https://gitlab.com/mailman/mailmanclient \
git+https://gitlab.com/mailman/postorius \
uwsgi \
'psycopg2<2.9' \
psycopg2 \
dj-database-url \
mysqlclient \
typing \
django-utils-six \
&& python3 -m pip install -U 'Django<3.2' \
&& python3 -m pip install -U \
&& python3 -m pip install --break-system-packages -U 'Django<4.3' \
&& python3 -m pip install --break-system-packages -U \
git+https://gitlab.com/mailman/django-mailman3 \
&& apk del .build-deps \
&& addgroup -S mailman \
&& adduser -S -G mailman mailman \
&& chown -R mailman /opt/mailman-web/ \
&& adduser -S -G mailman mailman
# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/
RUN chown -R mailman /opt/mailman-web/ \
&& chmod u+x /opt/mailman-web/manage.py
WORKDIR /opt/mailman-web

View File

@@ -7,7 +7,7 @@ function wait_for_postgres () {
# moving forward.
# TODO: Use python's psycopg2 module to do this in python instead of
# installing postgres-client in the image.
until psql $DATABASE_URL -c '\l'; do
until psql -P pager=off $DATABASE_URL -c '\l'; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done

View File

@@ -46,16 +46,14 @@ ADMINS = (
SITE_ID = 1
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.8/ref/settings/#allowed-hosts
# See https://docs.djangoproject.com/en/3.1/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [
"localhost", # Archiving API from Mailman, keep it.
# "lists.your-domain.org",
# Add here all production URLs you may have.
"mailman-web",
gethostbyname("mailman-web"),
os.environ.get('SERVE_FROM_DOMAIN'),
os.environ.get('DJANGO_ALLOWED_HOSTS'),
]
ALLOWED_HOSTS.extend(os.getenv("DJANGO_ALLOWED_HOSTS", "").split(","))
# Mailman API credentials
MAILMAN_REST_API_URL = os.environ.get('MAILMAN_REST_URL', 'http://mailman-core:8001')
@@ -78,6 +76,7 @@ DEFAULT_APPS = [
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django_gravatar',
'allauth',
'allauth.account',
@@ -101,6 +100,7 @@ MIDDLEWARE = (
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django_mailman3.middleware.TimezoneMiddleware',
'allauth.account.middleware.AccountMiddleware',
'postorius.middleware.PostoriusMiddleware',
)
@@ -143,6 +143,11 @@ DATABASES = {
'default': dj_database_url.config(conn_max_age=600)
}
# Avoid Django 3.2+ warning
# https://github.com/maxking/docker-mailman/issues/595
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# If you're behind a proxy, use the X-Forwarded-Host header
# See https://docs.djangoproject.com/en/1.8/ref/settings/#use-x-forwarded-host
USE_X_FORWARDED_HOST = True

View File

@@ -16,19 +16,18 @@
# You should have received a copy of the GNU General Public License along with
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import include, url
from django.conf.urls import include
from django.contrib import admin
from django.urls import reverse_lazy
from django.urls import re_path, reverse_lazy
from django.views.generic import RedirectView
urlpatterns = [
url(r'^$', RedirectView.as_view(
re_path(r'^$', RedirectView.as_view(
url=reverse_lazy('list_index'),
permanent=True)),
url(r'^postorius/', include('postorius.urls')),
url(r'', include('django_mailman3.urls')),
url(r'^accounts/', include('allauth.urls')),
re_path(r'postorius/', include('postorius.urls')),
re_path(r'', include('django_mailman3.urls')),
re_path(r'accounts/', include('allauth.urls')),
# Django admin
url(r'^admin/', admin.site.urls),
re_path(r'^admin/', admin.site.urls),
]

View File

@@ -3,7 +3,7 @@
uwsgi-socket = 0.0.0.0:8080
http-socket = 0.0.0.0:8000
# Move to the directory wher the django files are.
# Move to the directory where the django files are.
chdir = /opt/mailman-web
# Use the wsgi file provided with the django project.
@@ -14,7 +14,7 @@ master = true
processes = 2
threads = 2
# Drop privielges and don't run as root.
# Drop privileges and don't run as root.
uid = mailman
gid = mailman