From: Nicolas Lœuillet Date: Mon, 11 Jan 2016 08:08:39 +0000 (+0100) Subject: Merge pull request #1561 from FabienM/docker-compose X-Git-Tag: 2.0.0-alpha.2~15 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=0aafb8dfcb098ae586dc87f3487b4948f8ae2314;hp=4aa29971062dd41df89939b8e6c20e3ed2ed7183;p=github%2Fwallabag%2Fwallabag.git Merge pull request #1561 from FabienM/docker-compose Add basic docker-compose configuration --- diff --git a/.gitignore b/.gitignore index 9bde27db..f88370d7 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,7 @@ # Data for wallabag data/assets/* data/db/wallabag*.sqlite + +# Docker container logs and data +docker/logs/ +docker/data/ diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index a769bc66..0c0cbff1 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -1,5 +1,15 @@ # This file is a "template" of what your parameters.yml file should look like parameters: + # Uncomment these settings or manually update your parameters.yml + # to use docker-compose + # + # database_driver: %env.database_driver% + # database_host: %env.database_host% + # database_port: %env.database_port% + # database_name: %env.database_name% + # database_user: %env.database_user% + # database_password: %env.database_password% + database_driver: pdo_sqlite database_host: 127.0.0.1 database_port: ~ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..c774b621 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,42 @@ +nginx: + image: nginx + ports: + - "8080:80" + volumes: + - ./docker/nginx/nginx.conf:/nginx.conf + - ./docker/logs/nginx:/var/log/nginx + - .:/var/www/html + links: + - php:php + command: nginx -c /nginx.conf +php: + build: docker/php + ports: + - "9000:9000" + volumes: + - .:/var/www/html + #links: + # - "postgres:rdbms" + # - "mariadb:rdbms" + env_file: + - ./docker/php/env + # Comment non-used DBMS lines + # If all DBMS are commented out, sqlite will be used as default + # - ./docker/postgres/env + # - ./docker/mariadb/env +#postgres: +# image: postgres:9 +# ports: +# - "5432:5432" +# volumes: +# - ./docker/data/pgsql:/var/lib/postgresql/data +# env_file: +# - ./docker/postgres/env +#mariadb: +# image: mariadb:10 +# ports: +# - "3306:3306" +# volumes: +# - ./docker/data/mariadb:/var/lib/mysql +# env_file: +# - ./docker/mariadb/env diff --git a/docker/mariadb/env b/docker/mariadb/env new file mode 100644 index 00000000..87556a15 --- /dev/null +++ b/docker/mariadb/env @@ -0,0 +1,10 @@ +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 diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf new file mode 100644 index 00000000..7e82a0f8 --- /dev/null +++ b/docker/nginx/nginx.conf @@ -0,0 +1,89 @@ +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; diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 00000000..7c56ae57 --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,10 @@ +FROM php:fpm + +RUN apt-get update && apt-get install -y \ + libmcrypt-dev libicu-dev libpq-dev libxml2-dev \ + && docker-php-ext-install \ + iconv mcrypt mbstring intl pdo pdo_mysql pdo_pgsql + +RUN usermod -u 1000 www-data + +CMD ["php-fpm"] diff --git a/docker/php/env b/docker/php/env new file mode 100644 index 00000000..935134fc --- /dev/null +++ b/docker/php/env @@ -0,0 +1,6 @@ +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=~ diff --git a/docker/postgres/env b/docker/postgres/env new file mode 100644 index 00000000..80c78c2a --- /dev/null +++ b/docker/postgres/env @@ -0,0 +1,9 @@ +POSTGRES_USER=wallabag +POSTGRES_PASSWORD=wallapass +POSTGRES_DB=wallabag +export SYMFONY__ENV__DATABASE_DRIVER=pdo_pgsql +export SYMFONY__ENV__DATABASE_HOST=rdbms +export SYMFONY__ENV__DATABASE_PORT=5432 +export SYMFONY__ENV__DATABASE_NAME=wallabag +export SYMFONY__ENV__DATABASE_USER=wallabag +export SYMFONY__ENV__DATABASE_PASSWORD=wallapass diff --git a/docs/en/developer/docker.rst b/docs/en/developer/docker.rst new file mode 100644 index 00000000..9ed9dde2 --- /dev/null +++ b/docs/en/developer/docker.rst @@ -0,0 +1,51 @@ +Run Wallabag in docker-compose +============================== + +In order to run your own development instance of wallabag, you may +want to use the pre-configured docker compose files. + +Requirements +------------ + +Make sure to have `Docker +`__ and `Docker +Compose `__ availables on +your system and up to date. + +Switch DBMS +----------- + +By default, Wallabag will start with a sqlite database. +Since Wallabag provide support for Postgresql and MySQL, docker +containers are also available for these ones. + +In ``docker-compose.yml``, for the chosen DBMS uncomment : + +- the container definition (``postgres`` or ``mariadb`` root level + block) +- the container link in the ``php`` container +- the container env file in the ``php`` container + +In order to keep running Symfony commands on your host (such as +``wallabag:install``), you also should : + +- source the proper env files on your command line, so variables + like ``SYMFONY__ENV__DATABASE_HOST`` will exist. +- create a ``127.0.0.1 rdbms`` on your system ``hosts`` file + +Run Wallabag +------------ + +#. Fork and clone the project +#. Edit ``app/config/parameters.yml`` to replace ``database_*`` + properties with commented ones (with values prefixed by ``env.``) +#. ``composer install`` the project dependencies +#. ``php app/console wallabag:install`` to create the schema +#. ``docker-compose up`` to run the containers +#. Finally, browse to http://localhost:8080/ to find your freshly + installed wallabag. + +At various step, you'll probably run into UNIX permission problems, +bad paths in generated cache, etc… +Operations like removing cache files or changing files owners might +be frequently required, so don't be afraid !