Merge pull request #104 from ishitatsuyuki/alpine

Several changes:

- Move mailman-web image to python2.7:alpine-3.6 image, which is built on top of apline3.6 and contains the last remaining dependency that wasn't available in 3.5.
- Rename the entrypoint scripts in both core and web to docker-entrypoint.sh, and add them to somewhere on PATH so it is easy to call them in ENTRYPOINT
- Move to `sassc` for django-compressor.
- Set uwsgi uid/gid to string `mailman`
- Use alpine image for postgres database

thanks to @ishitatsuyuki !
This commit is contained in:
Abhilash Raj
2017-07-28 06:39:28 -07:00
committed by GitHub
7 changed files with 33 additions and 36 deletions

View File

@@ -3,7 +3,7 @@ FROM python:3.6-alpine
MAINTAINER Abhilash Raj MAINTAINER Abhilash Raj
#Add startup script to container #Add startup script to container
ADD assets/run.sh /opt/run.sh COPY docker-entrypoint.sh /usr/local/bin/
#Install all required packages, add user for executing mailman and set execution rights for startup script #Install all required packages, add user for executing mailman and set execution rights for startup script
RUN apk update \ RUN apk update \
@@ -12,8 +12,7 @@ RUN apk update \
&& pip install psycopg2 mailman==3.1.0 mailman-hyperkitty==1.1.0 \ && pip install psycopg2 mailman==3.1.0 mailman-hyperkitty==1.1.0 \
&& pip install pymysql \ && pip install pymysql \
&& apk del build-deps \ && apk del build-deps \
&& adduser -S mailman \ && adduser -S mailman
&& chmod a+x /opt/run.sh
# Change the working directory. # Change the working directory.
WORKDIR /opt/mailman WORKDIR /opt/mailman
@@ -23,5 +22,5 @@ EXPOSE 8001 8024
ENV MAILMAN_CONFIG_FILE /etc/mailman.cfg ENV MAILMAN_CONFIG_FILE /etc/mailman.cfg
ENTRYPOINT ["/opt/run.sh"] ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["/usr/local/bin/master"] CMD ["master"]

View File

@@ -45,7 +45,7 @@ services:
POSTGRES_USER: mailman POSTGRES_USER: mailman
POSTGRES_PASSWORD: mailmanpass POSTGRES_PASSWORD: mailmanpass
restart: always restart: always
image: postgres:9.6 image: postgres:9.6-alpine
volumes: volumes:
- /opt/mailman/database:/var/lib/postgresql/data - /opt/mailman/database:/var/lib/postgresql/data
networks: networks:

View File

@@ -1,34 +1,32 @@
FROM python:2.7 FROM python:2.7-alpine3.6
MAINTAINER Abhilash Raj MAINTAINER Abhilash Raj
ENV DEBIAN_FRONTEND=noninteractive
# Add needed files for uwsgi server + settings for django # Add needed files for uwsgi server + settings for django
ADD mailman-web /opt/mailman-web COPY mailman-web /opt/mailman-web
# Add startup script to container # Add startup script to container
ADD assets/run.sh /opt/run.sh COPY docker-entrypoint.sh /usr/local/bin/
# Install packages and dependencies for postorius and hyperkitty # 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 # Add user for executing apps, change ownership for uwsgi+django files and set execution rights for management script
RUN apt-get update \ RUN set -ex \
&& apt-get install -y --no-install-recommends ruby-sass \ && apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers postgresql-dev \
wget \ && apk add --no-cache --virtual .mailman-rundeps bash sassc postgresql-client \
postgresql-client \ && pip install -U mailmanclient==3.1.0 \
&& rm -rf /var/lib/apt/lists/* \ postorius==1.1.0 \
&& python -m pip install -U mailmanclient==3.1.0 \ hyperkitty==1.1.0 \
postorius==1.1.0 \ django-mailman3==1.1.0 \
hyperkitty==1.1.0 \ whoosh \
django-mailman3==1.1.0 \ uwsgi \
whoosh \ psycopg2 \
uwsgi \ dj-database-url \
psycopg2 \ pymysql \
dj-database-url \ && pip install -U django==1.10 \
pymysql \ && apk del --no-cache .build-deps \
&& python -m pip install -U django==1.10 \ && addgroup -S mailman \
&& useradd -M -U -u 1000 mailman \ && adduser -S -G mailman mailman \
&& chmod u+x /opt/run.sh \ && chown -R mailman /opt/mailman-web/ \
&& chown mailman /opt/mailman-web/* \ && chmod u+x /opt/mailman-web/manage.py
&& chmod u+x /opt/mailman-web/manage.py
WORKDIR /opt/mailman-web WORKDIR /opt/mailman-web
@@ -38,5 +36,5 @@ EXPOSE 8000 8080
# Use stop signal for uwsgi server # Use stop signal for uwsgi server
STOPSIGNAL SIGINT STOPSIGNAL SIGINT
ENTRYPOINT ["/opt/run.sh"] ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["uwsgi", "--ini", "/opt/mailman-web/uwsgi.ini"] CMD ["uwsgi", "--ini", "/opt/mailman-web/uwsgi.ini"]

View File

@@ -281,8 +281,8 @@ SOCIALACCOUNT_PROVIDERS = {
# #
COMPRESS_PRECOMPILERS = ( COMPRESS_PRECOMPILERS = (
('text/less', 'lessc {infile} {outfile}'), ('text/less', 'lessc {infile} {outfile}'),
('text/x-scss', 'sass -t compressed {infile} {outfile}'), ('text/x-scss', 'sassc -t compressed {infile} {outfile}'),
('text/x-sass', 'sass -t compressed {infile} {outfile}'), ('text/x-sass', 'sassc -t compressed {infile} {outfile}'),
) )
# On a production setup, setting COMPRESS_OFFLINE to True will bring a # On a production setup, setting COMPRESS_OFFLINE to True will bring a

View File

@@ -18,8 +18,8 @@ process = 2
threads = 2 threads = 2
# Drop privielges and don't run as root. # Drop privielges and don't run as root.
uid = 1000 uid = mailman
gid = 1000 gid = mailman
# Setup the django_q related worker processes. # Setup the django_q related worker processes.
attach-daemon = ./manage.py qcluster attach-daemon = ./manage.py qcluster