1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-06-27 16:36:00 +00:00

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

@ -2,9 +2,9 @@ MYSQL_ROOT_PASSWORD=wallaroot
MYSQL_USER=wallabag
MYSQL_PASSWORD=wallapass
MYSQL_DATABASE=wallabag
SYMFONY__ENV__DATABASE_DRIVER=pdo_mysql
SYMFONY__ENV__DATABASE_HOST=rdbms
SYMFONY__ENV__DATABASE_PORT=3306
SYMFONY__ENV__DATABASE_NAME=wallabag
SYMFONY__ENV__DATABASE_USER=wallabag
SYMFONY__ENV__DATABASE_PASSWORD=wallapass
DATABASE_DRIVER=pdo_mysql
DATABASE_HOST=mysql
DATABASE_PORT=3306
DATABASE_NAME=wallabag
DATABASE_USER=wallabag
DATABASE_PASSWORD=wallapass

View file

@ -1,89 +0,0 @@
user nginx;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log off;
error_log off;
gzip on;
gzip_disable "msie6";
open_file_cache max=100;
upstream php-upstream {
server php:9000;
}
server {
#server_name domain.tld www.domain.tld;
root /var/www/html/web;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# DEV
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass php-upstream;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_pass php-upstream;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/app.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
}
daemon off;

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

View file

@ -1,9 +1,10 @@
POSTGRES_USER=wallabag
POSTGRES_PASSWORD=wallapass
POSTGRES_DB=wallabag
SYMFONY__ENV__DATABASE_HOST=rdbms
SYMFONY__ENV__DATABASE_PORT=5432
SYMFONY__ENV__DATABASE_NAME=wallabag
SYMFONY__ENV__DATABASE_USER=wallabag
SYMFONY__ENV__DATABASE_PASSWORD=wallapass
SYMFONY__ENV__DATABASE_DRIVER=pdo_pgsql
DATABASE_HOST=postgres
DATABASE_PORT=5432
DATABASE_NAME=wallabag
DATABASE_USER=wallabag
DATABASE_PASSWORD=wallapass
DATABASE_DRIVER=pdo_pgsql
DATABASE_PATH=null