Update docker-compose and Dockerfile for dev env

This change should ease the spawn of a development environment.
It can be used as a vscode devcontainer.

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
Kevin Decherf
2022-03-12 19:37:47 +01:00
parent 71ffcdc710
commit f51008aef0
13 changed files with 245 additions and 162 deletions

View File

@ -1,8 +1,19 @@
FROM php:7.2-fpm
FROM php:8.0-fpm AS rootless
# Default timezone. To change it, use the argument in the docker-compose.yml file
ARG timezone='Europe/Paris'
ARG memorylimit='512M'
ARG DEBIAN_FRONTEND=noninteractive
ARG NODE_VERSION=14
RUN apt-get update \
&& apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release \
openssl \
software-properties-common
RUN curl 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key' | apt-key add - \
&& echo "deb https://deb.nodesource.com/node_${NODE_VERSION}.x $(lsb_release -cs) main" > /etc/apt/sources.list.d/nodesource.list
RUN apt-get update && apt-get install -y \
libmcrypt-dev \
@ -15,26 +26,71 @@ RUN apt-get update && apt-get install -y \
imagemagick \
libmagickwand-dev \
libtidy-dev \
git
RUN docker-php-ext-install \
iconv \
mbstring \
libonig-dev \
libzip-dev \
libfreetype6-dev \
zlib1g-dev \
git \
build-essential \
nodejs
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install -j "$(nproc)" \
bcmath \
gd \
gettext \
iconv \
intl \
mbstring \
opcache \
pdo \
pdo_mysql \
pdo_pgsql \
pdo_sqlite \
sockets \
tidy \
bcmath \
zip
RUN printf "\n" | pecl install imagick && docker-php-ext-enable imagick
RUN pecl install redis; \
pecl install imagick; \
pecl install xdebug; \
docker-php-ext-enable \
redis \
imagick \
xdebug \
;
RUN echo "date.timezone="$timezone > /usr/local/etc/php/conf.d/date_timezone.ini
RUN echo "memory_limit ="$memorylimit > /usr/local/etc/php/conf.d/memory_limit.ini
RUN npm install -g yarn
RUN usermod -u 1000 www-data
RUN curl -L -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
CMD ["php-fpm"]
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
COPY entrypoint.sh /entrypoint.sh
COPY config/ /opt/wallabag/config/
RUN mkdir -p \
/var/www/html/app/config/ \
/var/www/html/var/cache \
/var/www/html/web/assets \
/var/www/html/data \
/var/www/.cache
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php", "bin/console", "--env=dev", "server:run", "0.0.0.0:8000"]
FROM rootless AS default
ARG USER_UID=1000
ARG USER_GID=1000
RUN groupmod -g 1000 www-data ; \
usermod -u ${USER_UID} -g www-data www-data ; \
touch /usr/local/etc/php/conf.d/wallabag-php.ini \
/var/www/.yarnrc ; \
chown -R www-data: /var/www/html \
/usr/local/etc/php/conf.d/wallabag-php.ini \
/var/www/.cache \
/var/www/.yarnrc
USER www-data

View File

@ -0,0 +1,62 @@
parameters:
database_driver: ${DATABASE_DRIVER:-pdo_sqlite}
database_driver_class: ${DATABASE_DRIVER_CLASS:-~}
database_host: ${DATABASE_HOST:-127.0.0.1}
database_port: ${DATABASE_PORT:-~}
database_name: ${DATABASE_NAME:-symfony}
database_user: ${DATABASE_USER:-root}
database_password: ${DATABASE_PASSWORD:-~}
database_path: ${DATABASE_PATH:-"%kernel.root_dir%/data/wallabag.sqlite"}
database_table_prefix: wallabag_
database_socket: null
database_charset: ${DATABASE_CHARSET:-utf8}
domain_name: ${DOMAIN_NAME:-https://www.example.com}
server_name: ${SERVER_NAME:-"Your wallabag instance"}
mailer_transport: ${MAILER_TRANSPORT:-smtp}
mailer_user: ${MAILER_USER:-~}
mailer_password: ${MAILER_PASSWORD:-~}
mailer_host: ${MAILER_HOST:-127.0.0.1}
mailer_port: ${MAILER_PORT:-25}
mailer_encryption: ${MAILER_ENCRYPTION:-~}
mailer_auth_mode: ${MAILER_AUTH_MODE:-~}
locale: ${LOCALE:-en}
# A secret key that's used to generate certain security-related tokens
secret: ${SECRET:-~}
# two factor stuff
twofactor_auth: ${TWOFACTOR_AUTH:-true}
twofactor_sender: ${TWOFACTOR_SENDER:-no-reply@wallabag.org}
# fosuser stuff
fosuser_registration: ${FOSUSER_REGISTRATION:-true}
fosuser_confirmation: ${FOSUSER_CONFIRMATION:-true}
fos_oauth_server_access_token_lifetime: 3600
fos_oauth_server_refresh_token_lifetime: 1209600
from_email: ${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: ${REDIS_SCHEME:-tcp}
redis_host: ${REDIS_HOST:-redis}
redis_port: ${REDIS_PORT:-6379}
redis_path: ${REDIS_PATH:-~}
redis_password: ${REDIS_PASSWORD:-~}
# Sentry
sentry_dsn: ${SENTRY_DSN:-~}
session_handler: ${SESSION_HANDLER:-session.handler.native_file}

View File

@ -0,0 +1,10 @@
memory_limit = ${PHP_MEMORY_LIMIT:-512M}
max_execution_time = ${PHP_MAX_EXECUTION_TIME:-60}
date.time = ${PHP_TIMEZONE:-Europe/Paris}
session.save_handler = ${PHP_SESSION_HANDLER:-files}
session.save_path = "${PHP_SESSION_SAVE_PATH:-}"
upload_max_filesize = 10M

6
docker/php/entrypoint.sh Executable file
View File

@ -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 "$@"

View File

@ -1,6 +0,0 @@
SYMFONY__ENV__DATABASE_DRIVER=pdo_sqlite
SYMFONY__ENV__DATABASE_HOST=127.0.0.1
SYMFONY__ENV__DATABASE_PORT=~
SYMFONY__ENV__DATABASE_NAME=symfony
SYMFONY__ENV__DATABASE_USER=root
SYMFONY__ENV__DATABASE_PASSWORD=~

13
docker/php/env.example Normal file
View File

@ -0,0 +1,13 @@
DATABASE_DRIVER=pdo_sqlite
DATABASE_HOST=127.0.0.1
DATABASE_PORT=~
DATABASE_NAME=symfony
DATABASE_USER=root
DATABASE_PASSWORD=~
DATABASE_PATH="%kernel.project_dir%/data/wallabag.sqlite"
DOMAIN_NAME=http://localhost:8000
SECRET=ch4n63m31fy0uc4n
PHP_SESSION_SAVE_PATH=tcp://redis:6379?database=2
PHP_SESSION_HANDLER=redis
SESSION_HANDLER=~
TRUSTED_PROXIES=0.0.0.0/0

2
docker/php/xdebug Normal file
View File

@ -0,0 +1,2 @@
XDEBUG_MODE=debug
XDEBUG_TRIGGER=yes