diff --git a/.env b/.env new file mode 100644 index 000000000..81f3275eb --- /dev/null +++ b/.env @@ -0,0 +1,77 @@ +### Full documentation available at https://wodby.com/stacks/wordpress/docs/local +### +### IMAGES TAGS CONSIST OF [VERSION]-[STABILITY_TAG] +### +### [VERSION] is usually a version of application running in a container +### [VERSION] sometimes additionally includes major wordpress version (see nginx) +### [STABILITY_TAG] is a version of image (not application) +### [STABILITY_TAG] correspond to git tag of corresponding image repository +### +### EXAMPLE: wodby/mariadb:10.2-3.1.2 has MariaDB 10.2 and stability tag 3.0.2 +### New stability tags include patch updates for applications and other fixes/improvements +### Changelog for stability tag can be found at https://github.com/wodby/mariadb/releases +### +### !!! For better reliability NEVER USE image without stability tag + + +### PROJECT SETTINGS + +PROJECT_NAME=my_wordpress_project +PROJECT_BASE_URL=wp.docker.localhost + +DB_NAME=wordpress +DB_USER=wordpress +DB_PASSWORD=wordpress +DB_ROOT_PASSWORD=password +DB_HOST=mariadb + +### --- MARIADB ---- + +MARIADB_TAG=10.2-3.1.2 +#MARIADB_TAG=10.1-3.1.2 + +### --- VANILLA WORDPRESS ---- +### [WORDPRESS_VERSION]-[PHP_VERSION]-[STABILITY_TAG] + +WORDPRESS_TAG=4-7.2-4.2.2 +#WORDPRESS_TAG=4-7.1-4.2.2 +#WORDPRESS_TAG=4-7.0-4.2.2 +#WORDPRESS_TAG=4-5.6-4.2.2 + +### --- PHP ---- + +PHP_TAG=7.2-dev-4.2.2 +#PHP_TAG=7.1-dev-4.2.2 +#PHP_TAG=7.0-dev-4.2.2 +#PHP_TAG=5.6-dev-4.2.2 +#PHP_TAG=7.2-dev-macos-4.2.2 +#PHP_TAG=7.1-dev-macos-4.2.2 +#PHP_TAG=7.0-dev-macos-4.2.2 +#PHP_TAG=5.6-dev-macos-4.2.2 + +### --- NGINX ---- +### [WORDPRESS_VERSION]-[NGINX_VERSION]-[STABILITY_TAG] + +NGINX_TAG=4-1.13-4.0.2 +#NGINX_TAG=4-1.12-4.0.2 + +### --- REDIS --- + +REDIS_TAG=4.0-2.1.5 +#REDIS_TAG=3.2-2.1.5 + +### --- POSTGRESQL ---- + +POSTGRES_TAG=10.1-1.3.0 +#POSTGRES_TAG=9.6-1.3.0 +#POSTGRES_TAG=9.5-1.3.0 +#POSTGRES_TAG=9.4-1.3.0 +#POSTGRES_TAG=9.3-1.3.0 + +### OTHERS + +ADMINER_TAG=4.3-1.1.0 +APACHE_TAG=2.4-3.0.1 +ATHENAPDF_TAG=2.10.0 +VARNISH_TAG=4.1-2.3.0 +WEBGRIND_TAG=1.5-1.3.0 diff --git a/.travis.yml b/.travis.yml index 595257852..0658de762 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,10 @@ env: - WORDPRESS_VER=4 PHP_VER=5.6 script: + - set -e - make test + - cp docker.mk Makefile + - tar -czf docker4wordpress.tar.gz docker-compose.yml docker-sync.yml Makefile .env traefik.yml deploy: provider: releases @@ -20,13 +23,6 @@ deploy: skip_cleanup: true file_glob: true file: - - docker-compose.yml - - docker-sync.yml - - traefik.yml + - docker4wordpress.tar.gz on: tags: true - -notifications: - slack: - on_failure: never - secure: "QK1v3v7bNcgD3CvuUjzTEYOCTIzO/WlJziL1CAH8k9lxUepbpxhC26O4v0DBXEjwNKgolP7CAjdaNAItFgjPvIXQHM+jSr4FcLWndF4I99CdzA0Ql7zzC0sgtw1vG9tzR4oauLLI8lemmVdqZmFgQ3G063YSHTD0o8LfFmMtPCqQzjKq9Cx2QOIdgOGmjeODd6My0ZM+MhbtoTNGdm1M3J4IRIHM0wKQir+Bd9dYpW1itgYzHCugaYzc+ITaP472dqsa+ickR5eu5oWFuGbqHcCa4s/oWVBdxwJ9gp8dc4YfaetWNiNPSvqKPlTcCdFuteO9oHO/VNVXtUOJs0ZfZuaAvlopdwhkncGWq5xeAF9ImauIAzNCh2RuYrRAtqqBWxhiqjybUBI9YM1A9rPZWJrP8kxVq+8UD0tfHCwcnMv1xPCsZ/EmwzMBZw8ujJBZu4d3BOmxSvAxd4RsIEJrTewcLbNCvPaARNscD1yMWHdqx6o3G6tomQ3mZkf0q1iBCYu6gmDNwQ3Y3ruE5Db2hoCwwyo656ahakTT3R8f2+wGvJ4jWE0ve+rZMPGd7NKWQIwqHVSRZv7Fg86Sz/h1vBAEXMFWYoOO3bFt71tTKBk/l4OcNQbDxNm7UsyMQqFlSAey98tk9BNoV51yNQ0jlJVN1yD7B3eh/9jb1bkJTtw=" \ No newline at end of file diff --git a/Makefile b/Makefile index 7eb42e547..b44e53816 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,9 @@ --include env_make +include docker.mk .PHONY: test WORDPRESS_VER ?= 4 -PHP_VER ?= 7.1 - -default: test +PHP_VER ?= 7.2 test: - cd ./test/$(WORDPRESS_VER)/$(PHP_VER) && ./run.sh + cd ./test/$(WORDPRESS_VER) && PHP_VER=$(PHP_VER) ./run diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 000000000..15357675a --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,16 @@ +version: "2" + +services: + php: + image: wodby/wordpress:$WORDPRESS_TAG + environment: + PHP_FPM_CLEAR_ENV: "no" + volumes: + - codebase:/var/www/html + + nginx: + volumes: + - codebase:/var/www/html + +volumes: + codebase: diff --git a/docker-compose.yml b/docker-compose.yml index 0acca20e7..79f45e1dc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,100 +2,100 @@ version: "2" services: mariadb: - image: wodby/mariadb:10.2-3.0.2 -# image: wodby/mariadb:10.1-3.0.2 + image: wodby/mariadb:$MARIADB_TAG + container_name: "${PROJECT_NAME}_mariadb" + stop_grace_period: 30s environment: - MYSQL_ROOT_PASSWORD: password - MYSQL_DATABASE: wordpress - MYSQL_USER: wordpress - MYSQL_PASSWORD: wordpress + MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD + MYSQL_DATABASE: $DB_NAME + MYSQL_USER: $DB_USER + MYSQL_PASSWORD: $DB_PASSWORD # volumes: # - ./mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here. # - /path/to/mariadb/data/on/host:/var/lib/mysql # I want to manage volumes manually. -# postgres: -# image: wodby/postgres:10.1-1.2.0 -## image: wodby/postgres:9.6-1.2.0 -# environment: -# POSTGRES_PASSWORD: password -# POSTGRES_DB: wordpress -# POSTGRES_USER: wordpress -# volumes: -# - ./postgres-init:/docker-entrypoint-initdb.d # Place init file(s) here. -# - /path/to/postgres/data/on/host:/var/lib/postgresql/data # I want to manage volumes manually. - php: -# 1. Images with vanilla WordPress – wodby/wordpress:[WP_VERSION]-[PHP_VERSION]-[STABILITY_TAG]. - image: wodby/wordpress:4-7.2-3.3.1 -# image: wodby/wordpress:4-7.1-3.3.1 -# image: wodby/wordpress:4-7.0-3.3.1 -# image: wodby/wordpress:4-5.6-3.3.1 -# 2. Images without WordPress – wodby/wordpress-php:[PHP_VERSION]-[STABILITY_TAG]. -# image: wodby/wordpress-php:7.2-3.3.1 -# image: wodby/wordpress-php:7.1-3.3.1 -# image: wodby/wordpress-php:7.0-3.3.1 -# image: wodby/wordpress-php:5.6-3.3.1 -# 3. Images without WordPress – wodby/wordpress-php:[PHP_VERSION]-[STABILITY_TAG].Version for development (--enable-debug) -# image: wodby/wordpress-php:7.2-dev-3.3.1 -# image: wodby/wordpress-php:7.1-dev-3.3.1 -# image: wodby/wordpress-php:7.0-dev-3.3.1 -# image: wodby/wordpress-php:5.6-dev-3.3.1 + image: wodby/wordpress-php:$PHP_TAG + container_name: "${PROJECT_NAME}_php" environment: PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025 - PHP_FPM_CLEAR_ENV: "no" + DB_HOST: $DB_HOST + DB_USER: $DB_USER + DB_PASSWORD: $DB_PASSWORD + DB_NAME: $DB_NAME # PHP_XDEBUG: 1 # PHP_XDEBUG_DEFAULT_ENABLE: 1 # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" -# PHP_XDEBUG_PROFILER_OUTPUT_DIR: /mnt/files/xdebug/profiler -# PHP_XDEBUG_TRACE_OUTPUT_DIR: /mnt/files/xdebug/traces +# PHP_BLACKFIRE: 1 volumes: - - codebase:/var/www/html -## Options for macOS users (http://docs.docker4wordpress.org/en/latest/macos) -# - codebase:/var/www/html:cached # User-guided caching + - ./:/var/www/html +## For macOS users (https://wodby.com/stacks/wordpress/docs/local/docker-for-mac/) +# - ./:/var/www/html:cached # User-guided caching # - docker-sync:/var/www/html # Docker-sync ## For Xdebug profiler files # - files:/mnt/files nginx: - image: wodby/wordpress-nginx:4-1.13-3.0.2 -# image: wodby/wordpress-nginx:4-1.12-3.0.2 + image: wodby/wordpress-nginx:$NGINX_TAG + container_name: "${PROJECT_NAME}_nginx" + depends_on: + - php environment: NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off" NGINX_ERROR_LOG_LEVEL: debug NGINX_BACKEND_HOST: php volumes: - - codebase:/var/www/html -# Options for macOS users (http://docs.docker4wordpress.org/en/latest/macos) -# - codebase:/var/www/html:cached # User-guided caching + - ./:/var/www/html +# Options for macOS users (https://wodby.com/stacks/wordpress/docs/local/docker-for-mac/) +# - ./:/var/www/html:cached # User-guided caching # - docker-sync:/var/www/html # Docker-sync - depends_on: - - php labels: - 'traefik.backend=nginx' - 'traefik.port=80' - - 'traefik.frontend.rule=Host:wp.docker.localhost' + - 'traefik.frontend.rule=Host:${PROJECT_BASE_URL}' + + mailhog: + image: mailhog/mailhog + container_name: "${PROJECT_NAME}_mailhog" + labels: + - 'traefik.backend=mailhog' + - 'traefik.port=8025' + - 'traefik.frontend.rule=Host:mailhog.${PROJECT_BASE_URL}' + +# postgres: +# image: wodby/postgres:$POSTGRES_TAG +# container_name: "${PROJECT_NAME}_postgres" +# stop_grace_period: 30s +# environment: +# POSTGRES_PASSWORD: $DB_PASSWORD +# POSTGRES_DB: $DB_NAME +# POSTGRES_USER: $DB_USER +# volumes: +# - ./postgres-init:/docker-entrypoint-initdb.d # Place init file(s) here. +# - /path/to/postgres/data/on/host:/var/lib/postgresql/data # I want to manage volumes manually. # apache: -# image: wodby/php-apache:2.4-2.0.2 +# image: wodby/php-apache:$APACHE_TAG +# container_name: "${PROJECT_NAME}_apache" # depends_on: # - php # environment: # APACHE_LOG_LEVEL: debug # APACHE_BACKEND_HOST: php -# APACHE_SERVER_ROOT: /var/www/html # volumes: -# - codebase:/var/www/html -## Options for macOS users (http://docs.docker4wordpress.org/en/latest/macos) -## - codebase:/var/www/html:cached # User-guided caching +# - ./:/var/www/html +## For macOS users (https://wodby.com/stacks/wordpress/docs/local/docker-for-mac/) +## - ./:/var/www/html:cached # User-guided caching ## - docker-sync:/var/www/html # Docker-sync # labels: # - 'traefik.backend=apache' # - 'traefik.port=80' -# - 'traefik.frontend.rule=Host:wp.docker.localhost' +# - 'traefik.frontend.rule=Host:${PROJECT_BASE_URL}' # varnish: -# image: wodby/wordpress-varnish:4.1-2.3.1 +# image: wodby/wordpress-varnish:$VARNISH_TAG +# container_name: "${PROJECT_NAME}_varnish" # depends_on: # - nginx # environment: @@ -105,71 +105,80 @@ services: # labels: # - 'traefik.backend=varnish' # - 'traefik.port=6081' -# - 'traefik.frontend.rule=Host:varnish.wp.docker.localhost' +# - 'traefik.frontend.rule=Host:varnish.${PROJECT_BASE_URL}' # redis: -# image: wodby/redis:4.0-2.1.4 -## image: wodby/redis:3.2-2.1.4 +# container_name: "${PROJECT_NAME}_redis" +# image: wodby/redis:$REDIS_TAG + +# adminer: +# container_name: "${PROJECT_NAME}_adminer" +# image: wodby/adminer:$ADMINER_TAG +# environment: +# ADMINER_SALT: adminer-salt +# labels: +# - 'traefik.backend=adminer' +# - 'traefik.port=9000' +# - 'traefik.frontend.rule=Host:adminer.${PROJECT_BASE_URL}' + +# webgrind: +# image: wodby/webgrind:$WEBGRIND_TAG +# container_name: "${PROJECT_NAME}_webgrind" +# environment: +# WEBGRIND_PROFILER_DIR: /mnt/files/xdebug/profiler +# labels: +# - 'traefik.backend=webgrind' +# - 'traefik.port=8080' +# - 'traefik.frontend.rule=Host:webgrind.${PROJECT_BASE_URL}' +# volumes: +# - files:/mnt/files # pma: # image: phpmyadmin/phpmyadmin +# container_name: "${PROJECT_NAME}_pma" # environment: -# PMA_HOST: mariadb -# PMA_USER: wordpress -# PMA_PASSWORD: wordpress +# PMA_HOST: $DB_HOST +# PMA_USER: $DB_USER +# PMA_PASSWORD: $DB_PASSWORD # PHP_UPLOAD_MAX_FILESIZE: 1G # PHP_MAX_INPUT_VARS: 1G # labels: # - 'traefik.backend=pma' # - 'traefik.port=80' -# - 'traefik.frontend.rule=Host:pma.wp.docker.localhost' +# - 'traefik.frontend.rule=Host:pma.${PROJECT_BASE_URL}' # athenapdf: -# image: arachnysdocker/athenapdf-service:2.10.0 +# image: arachnysdocker/athenapdf-service:$ATHENAPDF_TAG +# container_name: "${PROJECT_NAME}_athenapdf" # environment: # WEAVER_AUTH_KEY: weaver-auth-key # WEAVER_ATHENA_CMD: "athenapdf -S" # WEAVER_MAX_WORKERS: 10 # WEAVER_MAX_CONVERSION_QUEUE: 50 # WEAVER_WORKER_TIMEOUT: 90 -# WEAVER_CONVERSION_FALLBACK: false +# WEAVER_CONVERSION_FALLBACK: "false" # blackfire: # image: blackfire/blackfire +# container_name: "${PROJECT_NAME}_blackfire" # environment: # BLACKFIRE_SERVER_ID: XXXXX # BLACKFIRE_SERVER_TOKEN: YYYYY -# webgrind: -# image: wodby/webgrind:1.5-1.0.0 -# environment: -# WEBGRIND_PROFILER_DIR: /mnt/files/xdebug/profiler -# labels: -# - 'traefik.backend=webgrind' -# - 'traefik.port=8080' -# - 'traefik.frontend.rule=Host:webgrind.wp.docker.localhost' -# volumes: -# - files:/mnt/files - - mailhog: - image: mailhog/mailhog - labels: - - 'traefik.backend=mailhog' - - 'traefik.port=8025' - - 'traefik.frontend.rule=Host:mailhog.wp.docker.localhost' - portainer: image: portainer/portainer + container_name: "${PROJECT_NAME}_portainer" command: --no-auth -H unix:///var/run/docker.sock volumes: - /var/run/docker.sock:/var/run/docker.sock labels: - 'traefik.backend=portainer' - 'traefik.port=9000' - - 'traefik.frontend.rule=Host:portainer.wp.docker.localhost' + - 'traefik.frontend.rule=Host:portainer.${PROJECT_BASE_URL}' traefik: image: traefik + container_name: "${PROJECT_NAME}_traefik" command: -c /dev/null --web --docker --logLevel=INFO ports: - '8000:80' @@ -177,8 +186,7 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock -volumes: - codebase: +#volumes: ## Docker-sync for macOS users # docker-sync: # external: true diff --git a/docker-sync.yml b/docker-sync.yml index a715f635a..5aa779204 100644 --- a/docker-sync.yml +++ b/docker-sync.yml @@ -3,9 +3,9 @@ version: "2" syncs: docker-sync: src: './' - sync_userid: '82' + sync_userid: '1000' sync_excludes: ['.gitignore', '.git/', '.idea/'] # docker-sync-another-project: # src: '/absolute/path/to/project/codebase' -# sync_userid: '82' +# sync_userid: '1000' # sync_excludes: ['.gitignore', '.git/', '.idea/'] diff --git a/docker.mk b/docker.mk new file mode 100644 index 000000000..17aad2cc9 --- /dev/null +++ b/docker.mk @@ -0,0 +1,26 @@ +include .env + +.PHONY: up down stop prune ps shell + +default: up + +up: + @echo "Starting up containers for for $(PROJECT_NAME)..." + docker-compose pull --parallel + docker-compose up -d --remove-orphans + +down: stop + +stop: + @echo "Stopping containers for $(PROJECT_NAME)..." + @docker-compose stop + +prune: + @echo "Removing containers for $(PROJECT_NAME)..." + @docker-compose down -v + +ps: + @docker ps --filter name='$(PROJECT_NAME)*' + +shell: + docker exec -ti $(shell docker ps --filter name='$(PROJECT_NAME)_php' --format "{{ .ID }}") sh \ No newline at end of file diff --git a/docs/access.md b/docs/access.md deleted file mode 100644 index b30fb0ce4..000000000 --- a/docs/access.md +++ /dev/null @@ -1,11 +0,0 @@ -# Accessing containers - -You can connect to any container by executing the following command: -```bash -$ docker-compose exec [service] sh -``` - -Make sure you're using correct users to access the container, e.g. use user www-data (82) for Nginx and PHP containers: -```bash -$ docker-compose exec php sh -``` diff --git a/docs/containers/apache.md b/docs/containers/apache.md deleted file mode 100644 index a4815626d..000000000 --- a/docs/containers/apache.md +++ /dev/null @@ -1,7 +0,0 @@ -# Apache - -To set apache as a default container uncomment apache service definition and comment nginx service definition. - -## Configuration - -Configuration is possible via environment variables. See the full list of variables on [GitHub](https://github.com/wodby/wordpress-apache). diff --git a/docs/containers/athenapdf.md b/docs/containers/athenapdf.md deleted file mode 100644 index cf16c72ca..000000000 --- a/docs/containers/athenapdf.md +++ /dev/null @@ -1,13 +0,0 @@ -# AthenaPDF - -AthenaPDF is a drop-in replacement for wkhtmltopdf - -Usage: - -```bash -$ curl http://athenapdf:8080/convert\?auth\=wodby-athenapdf\&url\=http://google.com/ |> out.pdf -``` - -## Configuration - -Configuration is possible via environment variables. See the full list of variables on [GitHub](https://github.com/arachnys/athenapdf/blob/master/weaver/conf/sample.env). \ No newline at end of file diff --git a/docs/containers/blackfire.md b/docs/containers/blackfire.md deleted file mode 100644 index aa95426ad..000000000 --- a/docs/containers/blackfire.md +++ /dev/null @@ -1,11 +0,0 @@ -# Blackfire - -You can profile your WordPress application via blackfire.io by following the next steps: - -* Enable blackfire probe extension by adding the environment variable `PHP_BLACKFIRE` with any value to PHP (WordPress) service -* Uncomment `blackfire` agent service in your docker compose file -* Specify values for `BLACKFIRE_SERVER_ID` and `BLACKFIRE_SERVER_TOKEN` environment variables (you can acquire them from your blackfire.io profile) -* Install blackfire companion extension for [Chrome](https://blackfire.io/docs/integrations/chrome) or [Firefox](https://blackfire.io/docs/integrations/firefox) -* Start profiling your app via the extension and see data from blackfire.io dashboard - -Fore more details please refer to the official documentation: https://blackfire.io/docs/introduction diff --git a/docs/containers/mariadb.md b/docs/containers/mariadb.md deleted file mode 100644 index 63f6c0dcf..000000000 --- a/docs/containers/mariadb.md +++ /dev/null @@ -1,34 +0,0 @@ -# MariaDB - -MariaDB uses a persistent volume defined in Dockerfile. - -## Data persistence - -Do not use `docker-compose down` command because it will purge MariaDB volume. Instead use `docker-compose stop`. If you restart Docker you WILL NOT lose your MariaDB data. - -Alternatively, you can manage your volumes manually by uncommenting the volume definition for `/var/lib/mysql`. Replace `/path/to/mariadb/data/on/host` to the preferred filepath on your host machine. This way, your db data will always persist. - -## Import existing database - -if you want to import your database, uncomment the following line in the compose file: -```yml -# - ./mariadb-init:/docker-entrypoint-initdb.d # Place init .sql .sql.gz .sh file(s) here -``` - -Create the volume directory `./mariadb-init` in the same directory as the compose file and put there your SQL file(s). All SQL files will be automatically imported once MariaDB container has started. - -## Export - -Exporting all databases: -```bash -docker-compose exec mariadb sh -c 'exec mysqldump --all-databases -uroot -p"root-password"' > databases.sql -``` - -Exporting a specific database: -```bash -docker-compose exec mariadb sh -c 'exec mysqldump -uroot -p"root-password" my-db' > my-db.sql -``` - -## Configuration - -Configuration is possible via environment variables. See the full list of variables on [GitHub](https://github.com/wodby/mariadb). diff --git a/docs/containers/nginx.md b/docs/containers/nginx.md deleted file mode 100644 index 43d319756..000000000 --- a/docs/containers/nginx.md +++ /dev/null @@ -1,8 +0,0 @@ -# Nginx - -Nginx is being used as a default http server. - -## Configuration - -Configuration is possible via environment variables. See the full list of variables on [GitHub](https://github.com/wodby/wordpress-nginx). - diff --git a/docs/containers/php.md b/docs/containers/php.md deleted file mode 100644 index 0e7264e48..000000000 --- a/docs/containers/php.md +++ /dev/null @@ -1,59 +0,0 @@ -# PHP - -PHP is used with Nginx via PHP-FPM. - -## WP CLI - -PHP container has installed wp cli. When running wp cli make sure to open the shell as user 82 (www-data) to avoid access problems in the web server, which is running as user 82, too: -```bash -$ docker-compose exec --user 82 php wp cli version -``` - -## Composer - -PHP container has installed composer. Example: -```bash -$ docker-compose exec --user 82 php composer update -``` - -## Xdebug - -If you want to use Xdebug, uncomment this line to enable it in the compose file before starting containers: -```yml -PHP_XDEBUG: 1 # Enable Xdebug extension -PHP_XDEBUG_DEFAULT_ENABLE: 1 # Comment out to disable (default). -``` - -If you would like to autostart xdebug, uncomment this line: -```yml -PHP_XDEBUG_REMOTE_AUTOSTART: 1 # Comment out to disable (default). -``` - -### Xdebug on macOS - -There are two more things that need to be done on macOS in order to have Xdebug working (because there's no docker0 interface). Enable Xdebug as described in the previous section and uncomment the following two lines: - -```yml -PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # Disabled for remote.host to work (enabled by default) -PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # Setting the host (localhost by default) -``` - -You also need to have loopback alias with IP from above. You need this only once and that settings stays active until logout or restart. - -```bash -sudo ifconfig lo0 alias 10.254.254.254 -``` - -### Xdebug on Windows - -You should do same things as for Mac OS. Enable Xdebug as described in the previous 2 sections and replace value of _PHP_XDEBUG_REMOTE_HOST_ to your DockerNAT ip assigned (by default it should be 10.0.75.1): - -```yml -PHP_XDEBUG_REMOTE_HOST: "10.0.75.1" # Setting the host (localhost by default) -``` - -You also need to check firewall not to block your connection. Disabling firewall should help. - -## Configuration - -Configuration is possible via environment variables. See the full list of variables on [GitHub](https://github.com/wodby/wordpress-php). diff --git a/docs/containers/postgres.md b/docs/containers/postgres.md deleted file mode 100644 index 141c30d38..000000000 --- a/docs/containers/postgres.md +++ /dev/null @@ -1,22 +0,0 @@ -# PostgreSQL - -PostgreSQL uses a persistent volume defined in Dockerfile. - -## Data persistence - -Do not use `docker-compose down` command because it will purge PostgreSQL volume. Instead use `docker-compose stop`. If you restart Docker you WILL NOT lose your PostgreSQL data. - -Alternatively, you can manage your volumes manually by uncommenting the volume definition for `/var/lib/postgresql/data`. Replace `/path/to/postgres/data/on/host` to the preferred filepath on your host machine. This way, your db data will always persist. - -## Import existing database - -if you want to import your database, uncomment the following line in the compose file: -```yml -# - ./postgres-init:/docker-entrypoint-initdb.d # Place init .sql .sql.gz .sh file(s) here -``` - -Create the volume directory `./postgres-init` in the same directory as the compose file and put there your SQL file(s). All SQL files will be automatically imported once PostgreSQL container has started. - -## Configuration - -Configuration is possible via environment variables. See the full list of variables on [GitHub](https://github.com/wodby/postgres). diff --git a/docs/containers/redis.md b/docs/containers/redis.md deleted file mode 100644 index 1c42d0f3a..000000000 --- a/docs/containers/redis.md +++ /dev/null @@ -1,18 +0,0 @@ -# Redis - -## Integration - -To spin up a container with Redis cache and use it as a default cache storage follow these steps: - -1. Uncomment lines with redis service definition in the compose file. -2. Download and install [Redis Object Cache plugin](https://wordpress.org/plugins/redis-cache/) -3. Add the following lines to the wp-config.php file: - -```php -define('WP_REDIS_HOST', 'redis'); -define('WP_REDIS_PORT', '6379'); -``` - -## Configuration - -Configuration is possible via environment variables. See the full list of variables on [GitHub](https://github.com/wodby/redis). \ No newline at end of file diff --git a/docs/containers/varnish.md b/docs/containers/varnish.md deleted file mode 100644 index 5bbdc3e4d..000000000 --- a/docs/containers/varnish.md +++ /dev/null @@ -1,7 +0,0 @@ -# Varnish - -TBD - -## Configuration - -Configuration is possible via environment variables. See the full list of variables on [GitHub](https://github.com/wodby/wordpress-varnish). \ No newline at end of file diff --git a/docs/containers/webgrind.md b/docs/containers/webgrind.md deleted file mode 100644 index bab1cc094..000000000 --- a/docs/containers/webgrind.md +++ /dev/null @@ -1,19 +0,0 @@ -# Webgrind - -[Webgrind](https://github.com/jokkedk/webgrind) allows you view and analyze Xdebug profiler output and generate call graphs for visualisation. - -Usage: - -1. Enable Xdebug profiler by uncommenting the following environment variables for `php` service: -``` -PHP_XDEBUG: 1 -PHP_XDEBUG_PROFILER_ENABLE: 1 -PHP_XDEBUG_PROFILER_ENABLE_TRIGGER: 1 -PHP_XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE: 1 -``` -2. Uncomment `webgrind` service in your docker-compose file -3. Uncomment `files` volume for `php` service and the definition in global volumes -4. Add `XDEBUG_PROFILE=1` param to GET or POST request (or set a cookie) you want to profile. Xdebug will generate profile files in `/mnt/files/xdebug/profiler` -5. Click Update in Webgrind to access the new information. See https://xdebug.org/docs/profiler to learn more about xdebug profiling. - -> ! IMPORTANT: Xdebug profiling significantly decreases performance and increases resources usage. DO NOT USE it on Production servers. diff --git a/docs/domains.md b/docs/domains.md deleted file mode 100644 index 53f849aec..000000000 --- a/docs/domains.md +++ /dev/null @@ -1,17 +0,0 @@ -# Domains configuration - -Docker4WordPress uses [traefik](https://hub.docker.com/_/traefik/) container for routing. By default, we use port `8000` to avoid potential conflicts but if port `80` is free on your host machine just replace traefik's ports definition in the compose file. - -Add `127.0.0.1 wp.docker.localhost` to your `/etc/hosts` file (some browsers like Chrome may work without it). Do the same for other default domains you might need from listed below: - -| Service | Domain | -| ------------ | -------------------------------------------------------------------------------------- | -| nginx/apache | [http://wp.docker.localhost:8000](http://wp.docker.localhost:8000) | -| pma | [http://pma.wp.docker.localhost:8000](http://pma.wp.docker.localhost:8000) | -| mailhog | [http://mailhog.wp.docker.localhost:8000](http://mailhog.wp.docker.localhost:8000) | -| varnish | [http://varnish.wp.docker.localhost:8000](http://varnish.wp.docker.localhost:8000) | -| athenapdf | [http://athenapdf.wp.docker.localhost:8000](http://athenapdf.wp.docker.localhost:8000) | -| webgrind | [http://webgrind.wp.docker.localhost:8000](http://webgrind.wp.docker.localhost:8000) | -| portainer | [http://portainer.wp.docker.localhost:8000](http://portainer.wp.docker.localhost:8000) | - -You can customize domains under labels definition, e.g. `traefik.frontend.rule=Host:mailhog.wp.docker.localhost`. Note: if domains end with `docker.localhost` you don't need to add records to /etc/hosts file diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 20b93044b..000000000 --- a/docs/index.md +++ /dev/null @@ -1,110 +0,0 @@ -# Getting Started - -Docker4WordPress is a set of docker containers optimized for WordPress. Use docker-compose.yml file from [docker4wordpress repository](https://github.com/wodby/docker4wordpress) to spin up local environment on Linux, Mac OS X and Windows. - -Docker4WordPress is designed to be used for local development, if you're looking for a production solution see [using in production](production.md). - -## Overview - -The WordPress stack consist of the following containers: - -[wodby/wordpress-nginx]: https://github.com/wodby/wordpress-nginx -[wodby/php-apache]: https://github.com/wodby/php-apache -[wodby/wordpress]: https://github.com/wodby/wordpress -[wodby/wordpress-php]: https://github.com/wodby/wordpress-php -[wodby/mariadb]: https://github.com/wodby/mariadb -[wodby/postgres]: https://github.com/wodby/postgres -[wodby/redis]: https://github.com/wodby/redis -[wodby/wordpress-varnish]: https://github.com/wodby/wordpress-varnish -[wodby/webgrind]: https://hub.docker.com/r/wodby/webgrind -[blackfire/blackfire]: https://hub.docker.com/r/blackfire/blackfire -[arachnysdocker/athenapdf-service]: https://hub.docker.com/r/arachnysdocker/athenapdf-service -[phpmyadmin/phpmyadmin]: https://hub.docker.com/r/phpmyadmin/phpmyadmin -[mailhog/mailhog]: https://hub.docker.com/r/mailhog/mailhog -[portainer/portainer]: https://hub.docker.com/r/portainer/portainer -[_/traefik]: https://hub.docker.com/_/traefik -[Nginx]: containers/nginx.md -[Apache]: containers/apache.md -[PHP]: containers/php.md -[MariaDB]: containers/mariadb.md -[PostgreSQL]: containers/postgres.md -[Redis]: containers/redis.md -[Varnish]: containers/varnish.md -[Webgrind]: containers/webgrind.md -[Blackfire]: containers/blackfire.md -[AthenaPDF]: containers/athenapdf.md - -| Container | Versions | Service name | Image | Enabled by default | -| ------------ | ---------- | ------------ | ---------------------------------- | ------------------ | -| [Nginx] | 1.13, 1.12 | `nginx` | [wodby/wordpress-nginx] | ✓ | -| [Apache] | 2.4 | `apache` | [wodby/php-apache] | | -| WordPress | 4 | `php` | [wodby/wordpress] | ✓ | -| [PHP] | 7.x, 5.6 | `php` | [wodby/wordpress-php] | | -| [MariaDB] | 10.2, 10.1 | `mariadb` | [wodby/mariadb] | ✓ | -| [PostgreSQL] | 10.1, 9.6 | `postgres` | [wodby/postgres] | | -| [Redis] | 4.0, 3.2 | `redis` | [wodby/redis] | | -| [Varnish] | 4.1 | `varnish` | [wodby/wordpress-varnish] | | -| [Webgrind] | 1.5 | `webgrind` | [wodby/webgrind] | | -| [Blackfire] | latest | `blackfire` | [blackfire/blackfire] | | -| [AthenaPDF] | 2.10.0 | `athenapdf` | [arachnysdocker/athenapdf-service] | | -| phpMyAdmin | latest | `pma` | [phpmyadmin/phpmyadmin] | | -| Mailhog | latest | `mailhog` | [mailhog/mailhog] | ✓ | -| Portainer | latest | `portainer` | [portainer/portainer] | ✓ | -| Traefik | latest | `traefik` | [_/traefik] | ✓ | - -Supported WordPress versions: 4 - -## Requirements - -* Install Docker ([Linux](https://docs.docker.com/engine/installation), [Docker for Mac](https://docs.docker.com/engine/installation/mac) or [Docker for Windows (10+ Pro)](https://docs.docker.com/engine/installation/windows)) -* For Linux additionally install [docker compose](https://docs.docker.com/compose/install) - -## Must know before you start - -1. To make sure you don't lose your MariaDB data DO NOT use `docker-compose down` (Docker will destroy volumes), instead use `docker-compose stop`. Alternatively, you can specify manual volume for `/var/lib/mysql` (see compose file), this way your data will always persist -2. To avoid potential problems with permissions between your host and containers please follow [this instructions](permissions.md) -3. _For macOS users_: Out of box Docker for Mac has [poor performance](https://github.com/Wodby/docker4wordpress/issues/4) on macOS. However there's a workaround based on [docker-sync project](https://github.com/EugenMayer/docker-sync/), read instructions [here](macos.md) -4. For better reliability we release images with stability tags (e.g. `wodby/wordpress-php:7.1-X.X.X`) which correspond to git tags. We strongly recommend using images only with stability tags. - -## Usage - -There 2 options how to use docker4wordpress – you can either run [vanilla](https://en.wikipedia.org/wiki/Vanilla_software) WordPress from the image or mount your own WordPress codebase: - -### 1. Run Vanilla WordPress from Image (default) - -1. Download `docker-compose.yml` file from the [latest stable release](https://github.com/wodby/docker4wordpress/releases) -2. Run containers: `docker-compose up -d` (it may take some time for them to initialize) -3. [Configure domains](domains.md) -4. That's it! Proceed with WordPress installation at [http://wp.docker.localhost:8000](http://wp.docker.localhost:8000). Default database user, password and database name are all `wordpress`, database host is `mariadb` -5. You can see status of your containers and their logs via portainer: [http://portainer.wp.docker.localhost:8000](http://portainer.wp.docker.localhost:8000) - -### 2. Mount my WordPress Codebase - -0. Read [must know before you start](#must-know-before-you-start) -1. Download `docker-compose.yml` file from the [latest stable release](https://github.com/wodby/docker4wordpress/releases) to your WordPress project root -2. Replace php image from `wodby/wordpress` (PHP + vanilla WordPress) to `wodby/wordpress-php` (just PHP) -3. Update _nginx/apache_ and _php_ volumes to `- ./:/var/www/html` to mount your codebase -4. Ensure your wp-config.php has the same credentials as _mariadb_ service -5. Optional: [import existing database](containers/mariadb.md#import-existing-database) -7. Optional: uncomment lines in the compose file to run _redis_, _varnish_, _phpmyadmin (pma)_ -8. [Configure domains](domains.md) -9. Run containers: `docker-compose up -d` -10. That's it! Your WordPress website should be up and running at [http://wp.docker.localhost:8000](http://wp.docker.localhost:8000). If you need to run multiple projects simultaneously see [this article](multiple-projects.md) -11. You can see status of your containers and their logs via portainer: [http://portainer.wp.docker.localhost:8000](http://portainer.wp.docker.localhost:8000) - -You can stop containers by executing: -```bash -docker-compose stop -``` - -Also, read [how to access containers](access.md) and [how to get logs](logs.md) - -## Status - -We're actively working on this instructions and containers. More options will be added soon. If you have a feature request or found a bug please [submit an issue on GitHub](https://github.com/wodby/docker4wordpress/issues/new) or [![Wodby Slack](https://www.google.com/s2/favicons?domain=www.slack.com) join us on Slack](https://slack.wodby.com/) - -We update containers from time to time by releasing new images tags. - -## License - -This project is licensed under the MIT open source license. diff --git a/docs/logs.md b/docs/logs.md deleted file mode 100644 index 1a65dc884..000000000 --- a/docs/logs.md +++ /dev/null @@ -1,17 +0,0 @@ -# Containers Logs - -## GUI - -You can find containers logs from portainer UI: [http://portainer.wp.docker.localhost:8000](http://portainer.wp.docker.localhost:8000) - -## CLI - -To get logs from a container simply run (skip the last param to get logs form all the containers): -``` -$ docker-compose logs [service] -``` - -Example: real-time logs of the PHP container: -``` -$ docker-compose logs -f php -``` diff --git a/docs/macos.md b/docs/macos.md deleted file mode 100644 index 3964ea3b3..000000000 --- a/docs/macos.md +++ /dev/null @@ -1,33 +0,0 @@ -# Docker for Mac Performance - -There 2 ways how can improve performance of docker volumes on macOS: - -## 1. User-guided Caching - -Since Docker for Mac 17.06 there's a new `:cached` option available for volumes. You can find more information about this in [docker blog](https://blog.docker.com/2017/05/user-guided-caching-in-docker-for-mac/). - -### Usage - -Replace _codebase_ volume definition of _php_ and _nginx_/_apache_ services with the option below marked as "User-guided caching". - -## 2. Docker-sync - -The core idea of this project is to use an external volume that will sync your files with a file synchronizer tool. - -### Installation - -```bash -$ gem install docker-sync -``` - -### Usage - -1. Download `docker-sync.yml` file from the [latest stable release](https://github.com/wodby/docker4wordpress/releases) -2. Uncomment _docker-sync_ volume definition in your compose file -3. Replace _volumes_ definition of _php_ and _nginx_/_apache_ services with the option below marked as "Docker-sync". -4. Start docker-sync: `docker-sync start` -5. In a new shell run after you started docker-sync `docker-compose up -d` - -Now when you change your code on the host machine docker-sync will sync your data to php and nginx/apache containers. - -For more information visit [docker-sync project page](https://github.com/EugenMayer/docker-sync/). diff --git a/docs/multiple-projects.md b/docs/multiple-projects.md deleted file mode 100644 index 716735ab7..000000000 --- a/docs/multiple-projects.md +++ /dev/null @@ -1,39 +0,0 @@ -# Running Multiple Projects with Træfik - -[Træfik](https://docs.traefik.io/) is a modern HTTP reverse proxy and load balancer made to deploy microservices with ease. -To understand the basics of Traefik it is suggested to check Træfik's documentation page: https://docs.traefik.io/ - - - -Image: Multi-domain set-up example -(Source: traefik.io) - -## Steps to set up two projects on one host ## - -1. Create two dirs where you will host two projects. Let's name them _site1_ and _site2_ -2. Copy `docker-compose.yml` file to both dirs (_site1_ and _site2_) -3. Download `traefik.yml` file from the [latest stable release](https://github.com/wodby/docker4wordpress/releases) to the parent dir where _site1_ and _site2_ dirs are -4. Edit `traefik.yml` and change `project1-dir_default` to `site1_default` and `project2-dir_default` to `site2_default`. Those are docker networks names that are created automatically from the dir name where docker-compose.yml is located -5. Edit site1's `docker-compose.yml` file. There are 3 main things that need to be done there: - * In nginx service, under labels, change `traefik.backend=nginx` to `traefik.backend=site1_nginx_1`. This is the name of the container. You can see that under NAMES when your have the containers running by executing `docker ps` - * Change `traefik.frontend.rule` from `Host:wp.docker.localhost` to `Host:site1.docker.localhost` - * Comment out all lines of `traefik` service at the bottom of the file -6. Make similar 3 changes in site2's `docker-compose.yml` file: - * `traefik.backend=nginx` to `traefik.backend=site2_nginx_1` - * `Host:wp.docker.localhost` to `Host:site2.docker.localhost` - * Comment out all lines of `traefik` service at the bottom of the file -7. Run `docker-compose up -d` in _site1_ and _site2_ dirs to spin up containers for both projects -8. Run stand-alone traefik `docker-compose -f traefik.yml up -d` to spin up traefik reverse proxy -9. Visit http://site1.docker.localhost and http://site2.docker.localhost in your browser - -This set up also works for other Docker projects (non WordPress and non docker4wordpress based). You can replace nginx-proxy config with Traefik and get other projects all routed with on traefik container. - -## Problems? ## - -* Check `docker ps` to see which containers are running and check if you have set up all names correctly. -* Check `docker network ls` to check if the network names are matching. -* Run `docker-compose logs -f` in site1 or site2 to see the log of each project. - -## Additional for macOS users with docker-sync: - -Names of `syncs` in docker-sync.yml file must be unique per project. The recommended way is to run stand-alone docker-sync with syncs definition for all projects. Do not forget to update `src` paths for projects. diff --git a/docs/permissions.md b/docs/permissions.md deleted file mode 100644 index cfb138ac3..000000000 --- a/docs/permissions.md +++ /dev/null @@ -1,35 +0,0 @@ -# Fixing Permissions Problems - -To avoid potential permissions problems between host machine and containers (e.g. can't access files generated by PHP) you can add a group on your host machine with ID 82, it's a standard GID/UID for www-data user in Alpine Linux. - -## Linux - -Create a new group with ID 82 and add yourself to this group. - -```bash -sudo groupadd -r -g 82 alpine-www-data -sudo usermod -a -G alpine-www-data $(id -un) -``` - -Another solution is to use ACL mechanism, available on most of Linux distributions. - -It's available by default on Ubuntu, with ext4 filesystem (starting from 14.04 version). -If you need more information, how to enable it on your Linux distribution, please check https://help.ubuntu.com/community/FilePermissionsACLs document. - -```bash -sudo setfacl -dR -m u:$(whoami):rwX -m u:82:rwX -m u:100:rX path_to_shared_volume -sudo setfacl -R -m u:$(whoami):rwX -m u:82:rwX -m u:100:rX path_to_shared_volume -``` -Code above will make sure that both your current user and php-fpm have full permissions to all files, and nginx worker has read-only access to all files in workspace. - -## macOS - -On macOS group with 82 already exists (_clamav). - -```bash -sudo dseditgroup -o edit -a $(id -un) -t user _clamav -``` - -## Windows - -TBD diff --git a/docs/production.md b/docs/production.md deleted file mode 100644 index c579fe937..000000000 --- a/docs/production.md +++ /dev/null @@ -1,3 +0,0 @@ -# Using in production - -Docker4WordPress is designed to be used for local development. Deploy docker-based WordPress stack with orchestrations to your own server via [![Wodby](https://www.google.com/s2/favicons?domain=wodby.com) Wodby](https://cloud.wodby.com/stackhub/a54a0f59-f4fd-49af-ad16-8d9ff776c50e). diff --git a/docs/redirect.js b/docs/redirect.js deleted file mode 100644 index 1b77597c7..000000000 --- a/docs/redirect.js +++ /dev/null @@ -1,4 +0,0 @@ -if (String(window.location).indexOf("readthedocs") !== -1) { - window.alert('The documentation has moved. I will redirect you to the new location.'); - window.location.replace('http://wodby.com/stacks/wordpress/docs/local'); -} \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml deleted file mode 100644 index 2fe2ad9c3..000000000 --- a/mkdocs.yml +++ /dev/null @@ -1,32 +0,0 @@ -site_name: Docker4WordPress Documentation - -repo_url: https://github.com/wodby/docker4wordpress -site_description: 'Docker4WordPress – Docker-based WordPress environment for local development' -theme: readthedocs - -markdown_extensions: - - toc: - permalink: True - -extra_javascript: ["redirect.js"] - -pages: - - Getting Started: 'index.md' - - Domains: 'domains.md' - - Logs: 'logs.md' - - Accessing Containers: 'access.md' - - Permissions: 'permissions.md' - - Docker for Mac: 'macos.md' - - Multiple Projects: 'multiple-projects.md' - - Using In Production: 'production.md' - - Containers: - - 'Nginx': 'containers/nginx.md' - - 'Apache': 'containers/apache.md' - - 'PHP': 'containers/php.md' - - 'MariaDB': 'containers/mariadb.md' - - 'PostgreSQL': 'containers/postgres.md' - - 'Redis': 'containers/redis.md' - - 'Varnish': 'containers/varnish.md' - - 'AthenaPDF': 'containers/athenapdf.md' - - 'Blackfire': 'containers/blackfire.md' - - 'Webgrind': 'containers/webgrind.md' diff --git a/test/4/.env b/test/4/.env new file mode 100644 index 000000000..5a55414c6 --- /dev/null +++ b/test/4/.env @@ -0,0 +1,14 @@ +PROJECT_BASE_URL=wordpress.docker.localhost + +DB_NAME=wordpress +DB_USER=wordpress +DB_PASSWORD=wordpress +DB_ROOT_PASSWORD=password +DB_HOST=mariadb + +MARIADB_TAG=10.2-3.1.2 +NGINX_TAG=4-1.13-4.0.2 +REDIS_TAG=4.0-2.1.5 +VARNISH_TAG=4.1-2.3.0 + +PHP_STABILITY_TAG=4.2.2 \ No newline at end of file diff --git a/test/4/5.6/run.sh b/test/4/5.6/run.sh deleted file mode 100755 index 607bd9d9d..000000000 --- a/test/4/5.6/run.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [[ -n "${DEBUG}" ]]; then - set -x -fi - -. ../../images.env - -# TODO: return health checks -docker-compose up -d -docker-compose exec mariadb make check-ready max_try=12 wait_seconds=3 -f /usr/local/bin/actions.mk -docker-compose exec php make check-ready -f /usr/local/bin/actions.mk -docker-compose exec --user=0 php chown -R www-data:www-data /var/www/html -docker-compose exec php ./test.sh -docker-compose down diff --git a/test/4/5.6/wp-config.php b/test/4/5.6/wp-config.php deleted file mode 100644 index b499e7dfa..000000000 --- a/test/4/5.6/wp-config.php +++ /dev/null @@ -1,92 +0,0 @@ -