Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Dockerfile rewrite #256

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.cache
__pycache__/*
*.pyc
/patches/*
!/patches/.keep
144 changes: 80 additions & 64 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,73 +1,89 @@
FROM alpine:3.12
FROM php:7.4.14-fpm-alpine

LABEL maintainer "Marvin Steadfast <marvin@xsteadfastx.org>"
ARG BASE=2.4.2

ARG WALLABAG_VERSION=2.4.2
WORKDIR /var/www/html

RUN apk add gnu-libiconv --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ --allow-untrusted
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php
ENV SYMFONY_ENV=prod

RUN set -ex \
&& apk update \
&& apk upgrade --available \
&& apk add \
ansible \
curl \
git \
libwebp \
mariadb-client \
nginx \
pcre \
php7 \
php7-amqp \
php7-bcmath \
php7-ctype \
php7-curl \
php7-dom \
php7-fpm \
php7-gd \
php7-gettext \
php7-iconv \
php7-json \
php7-mbstring \
php7-openssl \
php7-pdo_mysql \
php7-pdo_pgsql \
php7-pdo_sqlite \
php7-phar \
php7-session \
php7-simplexml \
php7-tokenizer \
php7-xml \
php7-zlib \
php7-sockets \
php7-xmlreader \
php7-tidy \
php7-intl \
py3-mysqlclient \
py3-psycopg2 \
py-simplejson \
rabbitmq-c \
s6 \
tar \
tzdata \
make \
bash \
&& rm -rf /var/cache/apk/* \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
&& curl -s https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
&& composer selfupdate --1 \
&& git clone --branch $WALLABAG_VERSION --depth 1 https://github.com/wallabag/wallabag.git /var/www/wallabag
RUN set -ex; \
\
apk add --no-cache --virtual .run-deps \
gnu-libiconv=1.15-r3 \
imagemagick6-libs \
tzdata \
; \
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
freetype-dev \
gettext-dev \
icu-dev \
imagemagick6-dev \
libjpeg-turbo-dev \
libpng-dev \
libxml2-dev \
libzip-dev \
oniguruma-dev \
postgresql-dev \
sqlite-dev \
tidyhtml-dev \
; \
docker-php-ext-configure gd --with-freetype --with-jpeg; \
docker-php-ext-install -j "$(nproc)" \
bcmath \
gd \
gettext \
iconv \
intl \
mbstring \
opcache \
pdo \
pdo_mysql \
pdo_pgsql \
pdo_sqlite \
sockets \
tidy \
zip \
; \
pecl install redis; \
pecl install imagick; \
docker-php-ext-enable \
redis \
imagick \
; \
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --virtual .wallabag-phpext-rundeps $runDeps; \
apk del .build-deps \
; \
apk add --virtual .composer-runtime-deps git patch; \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer; \
rm -rf /usr/src/* /tmp/pear/*

COPY root /
RUN wget -O /usr/local/bin/envsubst https://github.com/a8m/envsubst/releases/download/v1.1.0/envsubst-`uname -s`-`uname -m`; \
chmod +x /usr/local/bin/envsubst

RUN set -ex \
&& cd /var/www/wallabag \
&& SYMFONY_ENV=prod composer install --no-dev -o --prefer-dist --no-progress \
&& chown -R nobody:nobody /var/www/wallabag
RUN wget -O /tmp/wallabag.tar.gz https://github.com/wallabag/wallabag/archive/$BASE.tar.gz; \
mkdir /tmp/extract; \
tar xf /tmp/wallabag.tar.gz -C /tmp/extract; \
rmdir /var/www/html; \
mv /tmp/extract/wallabag-*/ /var/www/html; \
cd /var/www/html; \
composer install --no-dev --no-interaction -o --prefer-dist; \
chown -R www-data: /var/www/html; \
rm -rf /tmp/wallabag.tar.gz /tmp/extract /root/.composer /var/www/html/var/cache/prod;

COPY entrypoint.sh /entrypoint.sh
COPY config/ /opt/wallabag/config/
COPY patches/ /opt/wallabag/patches/
COPY apply-patches.sh /opt/wallabag/apply-patches.sh
RUN set -ex; \
/opt/wallabag/apply-patches.sh

EXPOSE 80
ENTRYPOINT ["/entrypoint.sh"]
CMD ["wallabag"]
CMD ["php-fpm"]
5 changes: 5 additions & 0 deletions apply-patches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

for i in $(find /opt/wallabag/patches/ -type f -name "*.patch" | sort); do
(cd /var/www/html ; echo "Applying ${i}…" ; patch -p1 < ${i})
done
62 changes: 62 additions & 0 deletions config/parameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
parameters:
database_driver: ${SYMFONY__ENV__DATABASE_DRIVER:-pdo_sqlite}
database_driver_class: ${SYMFONY__ENV__DATABASE_DRIVER_CLASS:-~}
database_host: ${SYMFONY__ENV__DATABASE_HOST:-127.0.0.1}
database_port: ${SYMFONY__ENV__DATABASE_PORT:-~}
database_name: ${SYMFONY__ENV__DATABASE_NAME:-symfony}
database_user: ${SYMFONY__ENV__DATABASE_USER:-root}
database_password: ${SYMFONY__ENV__DATABASE_PASSWORD:-~}
database_path: "%kernel.root_dir%/../data/db/wallabag.sqlite"
database_table_prefix: wallabag_
database_socket: null
database_charset: ${SYMFONY__ENV__DATABASE_CHARSET:-utf8}

domain_name: ${SYMFONY__ENV__DOMAIN_NAME:-https://your-wallabag-url-instance.com}
server_name: ${SYMFONY__ENV__SERVER_NAME:-"Your wallabag instance"}

mailer_transport: ${SYMFONY__ENV__MAILER_TRANSPORT:-smtp}
mailer_user: ${SYMFONY__ENV__MAILER_USER:-~}
mailer_password: ${SYMFONY__ENV__MAILER_PASSWORD:-~}
mailer_host: ${SYMFONY__ENV__MAILER_HOST:-127.0.0.1}
mailer_port: ${SYMFONY__ENV__MAILER_PORT:-25}
mailer_encryption: ${SYMFONY__ENV__MAILER_ENCRYPTION:-~}
mailer_auth_mode: ${SYMFONY__ENV__MAILER_AUTH_MODE:-~}

locale: ${SYMFONY__ENV__LOCALE:-en}

# A secret key that's used to generate certain security-related tokens
secret: ${SYMFONY__ENV__SECRET:-~}

# two factor stuff
twofactor_auth: ${SYMFONY__ENV__TWOFACTOR_AUTH:-true}
twofactor_sender: ${SYMFONY__ENV__TWOFACTOR_SENDER:-no-reply@wallabag.org}

# fosuser stuff
fosuser_registration: ${SYMFONY__ENV__FOSUSER_REGISTRATION:-true}
fosuser_confirmation: ${SYMFONY__ENV__FOSUSER_CONFIRMATION:-true}

fos_oauth_server_access_token_lifetime: 3600
fos_oauth_server_refresh_token_lifetime: 1209600

from_email: ${SYMFONY__ENV__FROM_EMAIL:-wallabag@example.com}

rss_limit: 50

# RabbitMQ processing
rabbitmq_host: localhost
rabbitmq_port: 5672
rabbitmq_user: guest
rabbitmq_password: guest
rabbitmq_prefetch_count: 10

# Redis processing
redis_scheme: ${SYMFONY__ENV__REDIS_SCHEME:-tcp}
redis_host: ${SYMFONY__ENV__REDIS_HOST:-redis}
redis_port: ${SYMFONY__ENV__REDIS_PORT:-6379}
redis_path: ${SYMFONY__ENV__REDIS_PATH:-~}
redis_password: ${SYMFONY__ENV__REDIS_PASSWORD:-~}

# Sentry
sentry_dsn: ${SYMFONY__ENV__SENTRY_DSN:-~}

session_handler: ${SESSION_HANDLER:-session.handler.native_file}
17 changes: 17 additions & 0 deletions config/wallabag-php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
memory_limit = ${PHP_MEMORY_LIMIT:-512M}

max_execution_time = ${PHP_MAX_EXECUTION_TIME:-60}

date.time = ${PHP_TIMEZONE:-Europe/Paris}

display_errors = off

session.save_handler = redis
session.save_path = "tcp://${PHP_SESSION_REDIS_HOST}:6379?database=2"

opcache.enable=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

envsubst < /opt/wallabag/config/wallabag-php.ini > /usr/local/etc/php/conf.d/wallabag-php.ini
envsubst < /opt/wallabag/config/parameters.yml > /var/www/html/app/config/parameters.yml

exec "$@"
Empty file added patches/.keep
Empty file.
28 changes: 0 additions & 28 deletions root/entrypoint.sh

This file was deleted.