diff --git a/.env b/.env index 1138e9315..d75f9bef7 100644 --- a/.env +++ b/.env @@ -1,17 +1,18 @@ #!/usr/bin/env bash -# See https://docs.docker.com/compose/environment-variables/#the-env-file +#Core [For container naming, eg. slug_nginx, slug_mysql] +APP_SLUG=mosha +CERT_EMAIL=name@mail.com # Nginx -NGINX_HOST=localhost +NGINX_HOST=mosharust.com +NGINX_VERSION=stable-alpine3.17 -# PHP - -# See https://hub.docker.com/r/nanoninja/php-fpm/tags/ -PHP_VERSION=latest +# PHP-FPM +PHP_VERSION=8.3-fpm # MySQL -MYSQL_VERSION=8.0.21 +MYSQL_VERSION=8.3.0 MYSQL_HOST=mysql MYSQL_DATABASE=test MYSQL_ROOT_USER=root diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 9a4aa7a18..000000000 --- a/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -# Global -.*.swp -.DS_Store - -# Application -web/app/composer.json -web/app/composer.lock -web/app/vendor/ -web/app/doc/ -web/app/report/ -data/ - -# PHPStorm -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -# Netbeans -nbproject/ -/nbproject/ -/nbproject/private/ -/nbproject/private/private.properties - -# VSCode -.vscode/ - -# SSL Certs -etc/ssl/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8ec197855..000000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -sudo: required - -env: - DOCKER_COMPOSE_VERSION: 1.18.0 - -services: - - docker - -before_install: - - sudo apt update - - sudo rm /usr/local/bin/docker-compose - - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose - - chmod +x docker-compose - - sudo mv docker-compose /usr/local/bin - - docker-compose --version - -before_script: - - sudo make docker-start - - sleep 2m - -script: - - sudo make apidoc - - sudo make gen-certs - - sudo make mysql-dump - - sudo make mysql-restore - - sudo make phpmd - - sudo make test - -after_script: - - sudo make docker-stop \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index b396bfdf2..000000000 --- a/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -# Makefile for Docker Nginx PHP Composer MySQL - -include .env - -# MySQL -MYSQL_DUMPS_DIR=data/db/dumps - -help: - @echo "" - @echo "usage: make COMMAND" - @echo "" - @echo "Commands:" - @echo " apidoc Generate documentation of API" - @echo " code-sniff Check the API with PHP Code Sniffer (PSR2)" - @echo " clean Clean directories for reset" - @echo " composer-up Update PHP dependencies with composer" - @echo " docker-start Create and start containers" - @echo " docker-stop Stop and clear all services" - @echo " gen-certs Generate SSL certificates" - @echo " logs Follow log output" - @echo " mysql-dump Create backup of all databases" - @echo " mysql-restore Restore backup of all databases" - @echo " phpmd Analyse the API with PHP Mess Detector" - @echo " test Test application" - -init: - @$(shell cp -n $(shell pwd)/web/app/composer.json.dist $(shell pwd)/web/app/composer.json 2> /dev/null) - -apidoc: - @docker run --rm -v $(shell pwd):/data phpdoc/phpdoc -i=vendor/ -d /data/web/app/src -t /data/web/app/doc - @make resetOwner - -clean: - @rm -Rf data/db/mysql/* - @rm -Rf $(MYSQL_DUMPS_DIR)/* - @rm -Rf web/app/vendor - @rm -Rf web/app/composer.lock - @rm -Rf web/app/doc - @rm -Rf web/app/report - @rm -Rf etc/ssl/* - -code-sniff: - @echo "Checking the standard code..." - @docker-compose exec -T php ./app/vendor/bin/phpcs -v --standard=PSR2 app/src - -composer-up: - @docker run --rm -v $(shell pwd)/web/app:/app composer update - -docker-start: init - docker-compose up -d - -docker-stop: - @docker-compose down -v - @make clean - -gen-certs: - @docker run --rm -v $(shell pwd)/etc/ssl:/certificates -e "SERVER=$(NGINX_HOST)" jacoelho/generate-certificate - -logs: - @docker-compose logs -f - -mysql-dump: - @mkdir -p $(MYSQL_DUMPS_DIR) - @docker exec $(shell docker-compose ps -q mysqldb) mysqldump --all-databases -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" > $(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null - @make resetOwner - -mysql-restore: - @docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < $(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null - -phpmd: - @docker-compose exec -T php \ - ./app/vendor/bin/phpmd \ - ./app/src text cleancode,codesize,controversial,design,naming,unusedcode - -test: code-sniff - @docker-compose exec -T php ./app/vendor/bin/phpunit --colors=always --configuration ./app/ - @make resetOwner - -resetOwner: - @$(shell chown -Rf $(SUDO_USER):$(shell id -g -n $(SUDO_USER)) $(MYSQL_DUMPS_DIR) "$(shell pwd)/etc/ssl" "$(shell pwd)/web/app" 2> /dev/null) - -.PHONY: clean test code-sniff init \ No newline at end of file diff --git a/README.md b/README.md index faae0b8b9..a004d7096 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,6 @@ -# Nginx PHP MySQL [![Build Status](https://travis-ci.org/nanoninja/docker-nginx-php-mysql.svg?branch=master)](https://travis-ci.org/nanoninja/docker-nginx-php-mysql) [![GitHub version](https://badge.fury.io/gh/nanoninja%2Fdocker-nginx-php-mysql.svg)](https://badge.fury.io/gh/nanoninja%2Fdocker-nginx-php-mysql) +# Nginx PHP MySQL -Docker running Nginx, PHP-FPM, Composer, MySQL and PHPMyAdmin. - -## Overview - -1. [Install prerequisites](#install-prerequisites) - - Before installing project make sure the following prerequisites have been met. - -2. [Clone the project](#clone-the-project) - - We’ll download the code from its repository on GitHub. - -3. [Configure Nginx With SSL Certificates](#configure-nginx-with-ssl-certificates) [`Optional`] - - We'll generate and configure SSL certificate for nginx before running server. - -4. [Configure Xdebug](#configure-xdebug) [`Optional`] - - We'll configure Xdebug for IDE (PHPStorm or Netbeans). - -5. [Run the application](#run-the-application) - - By this point we’ll have all the project pieces in place. - -6. [Use Makefile](#use-makefile) [`Optional`] - - When developing, you can use `Makefile` for doing recurrent operations. - -7. [Use Docker Commands](#use-docker-commands) - - When running, you can use docker commands for doing recurrent operations. - -___ +Docker running Nginx, PHP-FPM, MySQL. ## Install prerequisites @@ -49,21 +17,12 @@ All requisites should be available for your distribution. The most important are * [Git](https://git-scm.com/downloads) * [Docker](https://docs.docker.com/engine/installation/) * [Docker Compose](https://docs.docker.com/compose/install/) +* [Certbot](https://hub.docker.com/r/certbot/certbot) -Check if `docker-compose` is already installed by entering the following command : +Check if `docker compose` is already installed by entering the following command : ```sh -which docker-compose -``` - -Check Docker Compose compatibility : - -* [Compose file version 3 reference](https://docs.docker.com/compose/compose-file/) - -The following is optional but makes life more enjoyable : - -```sh -which make +docker compose ``` On Ubuntu and Debian these are available in the meta-package build-essential. On other distributions, you may need to install the GNU C++ compiler separately. @@ -76,10 +35,7 @@ sudo apt install build-essential * [Nginx](https://hub.docker.com/_/nginx/) * [MySQL](https://hub.docker.com/_/mysql/) -* [PHP-FPM](https://hub.docker.com/r/nanoninja/php-fpm/) -* [Composer](https://hub.docker.com/_/composer/) -* [PHPMyAdmin](https://hub.docker.com/r/phpmyadmin/phpmyadmin/) -* [Generate Certificate](https://hub.docker.com/r/jacoelho/generate-certificate/) +* [PHP-FPM](https://hub.docker.com/_/php) You should be careful when installing third party web servers such as MySQL or Nginx. @@ -88,37 +44,19 @@ This project use the following ports : | Server | Port | |------------|------| | MySQL | 8989 | -| PHPMyAdmin | 8080 | -| Nginx | 8000 | -| Nginx SSL | 3000 | +| Nginx | 80 | +| Nginx SSL | 443 | ___ -## Clone the project - -To install [Git](http://git-scm.com/book/en/v2/Getting-Started-Installing-Git), download it and install following the instructions : - -```sh -git clone https://github.com/nanoninja/docker-nginx-php-mysql.git -``` - -Go to the project directory : - -```sh -cd docker-nginx-php-mysql -``` - ### Project tree ```sh . -├── Makefile -├── README.md ├── data │ └── db │ ├── dumps │ └── mysql -├── doc ├── docker-compose.yml ├── etc │ ├── nginx @@ -128,14 +66,6 @@ cd docker-nginx-php-mysql │ │ └── php.ini │ └── ssl └── web - ├── app - │ ├── composer.json.dist - │ ├── phpunit.xml.dist - │ ├── src - │ │ └── Foo.php - │ └── test - │ ├── FooTest.php - │ └── bootstrap.php └── public └── index.php ``` @@ -144,15 +74,7 @@ ___ ## Configure Nginx With SSL Certificates -You can change the host name by editing the `.env` file. - -If you modify the host name, do not forget to add it to the `/etc/hosts` file. - -1. Generate SSL certificates - - ```sh - source .env && docker run --rm -v $(pwd)/etc/ssl:/certificates -e "SERVER=$NGINX_HOST" jacoelho/generate-certificate - ``` +1. [HowTo](https://dev.to/mrshanas/https-on-docker-containers-using-nginx-and-letsencrypt-3nfa) 2. Configure Nginx @@ -169,194 +91,8 @@ If you modify the host name, do not forget to add it to the `/etc/hosts` file. # ... # } ``` - ___ -## Configure Xdebug - -If you use another IDE than [PHPStorm](https://www.jetbrains.com/phpstorm/) or [Netbeans](https://netbeans.org/), go to the [remote debugging](https://xdebug.org/docs/remote) section of Xdebug documentation. - -For a better integration of Docker to PHPStorm, use the [documentation](https://github.com/nanoninja/docker-nginx-php-mysql/blob/master/doc/phpstorm-macosx.md). - -1. Get your own local IP address : - - ```sh - sudo ifconfig - ``` - -2. Edit php file `etc/php/php.ini` and comment or uncomment the configuration as needed. - -3. Set the `remote_host` parameter with your IP : - - ```sh - xdebug.remote_host=192.168.0.1 # your IP - ``` -___ - -## Run the application - -1. Copying the composer configuration file : - - ```sh - cp web/app/composer.json.dist web/app/composer.json - ``` - -2. Start the application : - - ```sh - docker-compose up -d - ``` - - **Please wait this might take a several minutes...** - - ```sh - docker-compose logs -f # Follow log output - ``` - -3. Open your favorite browser : - - * [http://localhost:8000](http://localhost:8000/) - * [https://localhost:3000](https://localhost:3000/) ([HTTPS](#configure-nginx-with-ssl-certificates) not configured by default) - * [http://localhost:8080](http://localhost:8080/) PHPMyAdmin (username: dev, password: dev) - -4. Stop and clear services - - ```sh - docker-compose down -v - ``` - -___ - -## Use Makefile - -When developing, you can use [Makefile](https://en.wikipedia.org/wiki/Make_(software)) for doing the following operations : - -| Name | Description | -|---------------|----------------------------------------------| -| apidoc | Generate documentation of API | -| clean | Clean directories for reset | -| code-sniff | Check the API with PHP Code Sniffer (`PSR2`) | -| composer-up | Update PHP dependencies with composer | -| docker-start | Create and start containers | -| docker-stop | Stop and clear all services | -| gen-certs | Generate SSL certificates for `nginx` | -| logs | Follow log output | -| mysql-dump | Create backup of all databases | -| mysql-restore | Restore backup of all databases | -| phpmd | Analyse the API with PHP Mess Detector | -| test | Test application with phpunit | - -### Examples - -Start the application : - -```sh -make docker-start -``` - -Show help : - -```sh -make help -``` - -___ - -## Use Docker commands - -### Installing package with composer - -```sh -docker run --rm -v $(pwd)/web/app:/app composer require symfony/yaml -``` - -### Updating PHP dependencies with composer - -```sh -docker run --rm -v $(pwd)/web/app:/app composer update -``` - -### Generating PHP API documentation - -```sh -docker run --rm -v $(pwd):/data phpdoc/phpdoc -i=vendor/ -d /data/web/app/src -t /data/web/app/doc -``` - -### Testing PHP application with PHPUnit - -```sh -docker-compose exec -T php ./app/vendor/bin/phpunit --colors=always --configuration ./app -``` - -### Fixing standard code with [PSR2](http://www.php-fig.org/psr/psr-2/) - -```sh -docker-compose exec -T php ./app/vendor/bin/phpcbf -v --standard=PSR2 ./app/src -``` - -### Checking the standard code with [PSR2](http://www.php-fig.org/psr/psr-2/) - -```sh -docker-compose exec -T php ./app/vendor/bin/phpcs -v --standard=PSR2 ./app/src -``` - -### Analyzing source code with [PHP Mess Detector](https://phpmd.org/) - -```sh -docker-compose exec -T php ./app/vendor/bin/phpmd ./app/src text cleancode,codesize,controversial,design,naming,unusedcode -``` - -### Checking installed PHP extensions - -```sh -docker-compose exec php php -m -``` - -### Handling database - -#### MySQL shell access - -```sh -docker exec -it mysql bash -``` - -and - -```sh -mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" -``` - -#### Creating a backup of all databases - -```sh -mkdir -p data/db/dumps -``` - -```sh -source .env && docker exec $(docker-compose ps -q mysqldb) mysqldump --all-databases -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" > "data/db/dumps/db.sql" -``` - -#### Restoring a backup of all databases - -```sh -source .env && docker exec -i $(docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < "data/db/dumps/db.sql" -``` - -#### Creating a backup of single database - -**`Notice:`** Replace "YOUR_DB_NAME" by your custom name. - -```sh -source .env && docker exec $(docker-compose ps -q mysqldb) mysqldump -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" --databases YOUR_DB_NAME > "data/db/dumps/YOUR_DB_NAME_dump.sql" -``` - -#### Restoring a backup of single database - -```sh -source .env && docker exec -i $(docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < "data/db/dumps/YOUR_DB_NAME_dump.sql" -``` - - #### Connecting MySQL from [PDO](http://php.net/manual/en/book.pdo.php) ```php @@ -369,9 +105,3 @@ source .env && docker exec -i $(docker-compose ps -q mysqldb) mysql -u"$MYSQL_RO } ?> ``` - -___ - -## Help us - -Any thought, feedback or (hopefully not!) \ No newline at end of file diff --git a/doc/configure-cacert-for-local-macosx.md b/doc/configure-cacert-for-local-macosx.md deleted file mode 100644 index 5af87dbfd..000000000 --- a/doc/configure-cacert-for-local-macosx.md +++ /dev/null @@ -1,26 +0,0 @@ -# Configure Local CA CERT with MacOS - -## 1. The warning you receive while developing locally. - -![Warning](images/cacert-1-warning.png) - -## 2. Open the keychain app. - -![Open Keychain](images/cacert-2-open-keychain.png) - -## 3. Use File --> Import to add the ca cert you've already created. - -![Add CA Cert](images/cacert-3-add-cacert-file-import.png) - -## 4. Once added, locate it via the search box. - -![Localhost Search Box](images/cacert-4-locate-cert.png) - -## 5. Set to always trust. - -![Trust The Cert](images/cacert-5-set-to-always-trust.png) - -## 6. Reload the webpage. - -![The Results](images/cacert-6-reload-page.png) - diff --git a/doc/images/cacert-1-warning.png b/doc/images/cacert-1-warning.png deleted file mode 100644 index 2a1365b65..000000000 Binary files a/doc/images/cacert-1-warning.png and /dev/null differ diff --git a/doc/images/cacert-2-open-keychain.png b/doc/images/cacert-2-open-keychain.png deleted file mode 100644 index 7a90788be..000000000 Binary files a/doc/images/cacert-2-open-keychain.png and /dev/null differ diff --git a/doc/images/cacert-3-add-cacert-file-import.png b/doc/images/cacert-3-add-cacert-file-import.png deleted file mode 100644 index f7dea1fbb..000000000 Binary files a/doc/images/cacert-3-add-cacert-file-import.png and /dev/null differ diff --git a/doc/images/cacert-4-locate-cert.png b/doc/images/cacert-4-locate-cert.png deleted file mode 100644 index 4031a8a5e..000000000 Binary files a/doc/images/cacert-4-locate-cert.png and /dev/null differ diff --git a/doc/images/cacert-5-set-to-always-trust.png b/doc/images/cacert-5-set-to-always-trust.png deleted file mode 100644 index 6e7fee09d..000000000 Binary files a/doc/images/cacert-5-set-to-always-trust.png and /dev/null differ diff --git a/doc/images/cacert-6-reload-page.png b/doc/images/cacert-6-reload-page.png deleted file mode 100644 index 3bbeb4201..000000000 Binary files a/doc/images/cacert-6-reload-page.png and /dev/null differ diff --git a/doc/images/ps-mac-php-cli-add-interpreter.png b/doc/images/ps-mac-php-cli-add-interpreter.png deleted file mode 100644 index 46b5aca76..000000000 Binary files a/doc/images/ps-mac-php-cli-add-interpreter.png and /dev/null differ diff --git a/doc/images/ps-mac-php-interpreter.png b/doc/images/ps-mac-php-interpreter.png deleted file mode 100644 index 48ba727cc..000000000 Binary files a/doc/images/ps-mac-php-interpreter.png and /dev/null differ diff --git a/doc/images/ps-mac-php-phpunit-config.png b/doc/images/ps-mac-php-phpunit-config.png deleted file mode 100644 index fb64c33e7..000000000 Binary files a/doc/images/ps-mac-php-phpunit-config.png and /dev/null differ diff --git a/doc/images/ps-mac-php-phpunit-demo.png b/doc/images/ps-mac-php-phpunit-demo.png deleted file mode 100644 index c76b06d87..000000000 Binary files a/doc/images/ps-mac-php-phpunit-demo.png and /dev/null differ diff --git a/doc/images/ps-mac-php-phpunit.png b/doc/images/ps-mac-php-phpunit.png deleted file mode 100644 index a9bff94d3..000000000 Binary files a/doc/images/ps-mac-php-phpunit.png and /dev/null differ diff --git a/doc/images/ps-mac-php-xdebug-demo.png b/doc/images/ps-mac-php-xdebug-demo.png deleted file mode 100644 index 9d520deac..000000000 Binary files a/doc/images/ps-mac-php-xdebug-demo.png and /dev/null differ diff --git a/doc/images/ps-mac-php-xdebug-proxy.png b/doc/images/ps-mac-php-xdebug-proxy.png deleted file mode 100644 index 6c88dca09..000000000 Binary files a/doc/images/ps-mac-php-xdebug-proxy.png and /dev/null differ diff --git a/doc/images/ps-mac-php-xdebug-server.png b/doc/images/ps-mac-php-xdebug-server.png deleted file mode 100644 index 77014ce5f..000000000 Binary files a/doc/images/ps-mac-php-xdebug-server.png and /dev/null differ diff --git a/doc/images/ps-mac-php-xdebug.png b/doc/images/ps-mac-php-xdebug.png deleted file mode 100644 index 08da762c7..000000000 Binary files a/doc/images/ps-mac-php-xdebug.png and /dev/null differ diff --git a/doc/phpstorm-macosx.md b/doc/phpstorm-macosx.md deleted file mode 100644 index 177946d9d..000000000 --- a/doc/phpstorm-macosx.md +++ /dev/null @@ -1,71 +0,0 @@ -# Configure PHPStorm with MacOS - -Inspired from this following links : - -- [Running PHPUnit Tests in PhpStorm with Docker](https://www.youtube.com/watch?v=I7aGWO6K3Ho) -- [All hail Xdebug and lets let var dump die](http://jamescowie.me/blog/2016/12/all-hail-xdebug-and-lets-let-var-dump-die/) - -## Edit PHP configuration - -![PHP CLI Interpreter](images/ps-mac-php-interpreter.png) - -## Add a PHP interpreter - -![Add PHP CLI Interpreter](images/ps-mac-php-cli-add-interpreter.png) - -## Configure PHPUnit - -![PHPUnit](images/ps-mac-php-phpunit.png) - -### Add test configuration - -![PHPUnit Config](images/ps-mac-php-phpunit-config.png) - -### PHPUnit Demo - -![PHPUnit Demo](images/ps-mac-php-phpunit-demo.png) - -## Configure XDebug - -### Edit `etc/php.ini` file - -Add this following lines : - -```sh -[xdebug] -xdebug.remote_host = 10.254.254.254 -xdebug.remote_port = 9000 -xdebug.remote_autostart=1 -xdebug.idekey = PHPSTORM -xdebug.remote_enable = 1 -xdebug.remote_connect_back = 0 -xdebug.profiler_enable = 1 -``` - -### Check Debug section - -![Xdebug](images/ps-mac-php-xdebug.png) - -### Add a debug server - -![XDebug Server](images/ps-mac-php-xdebug-server.png) - -### Configure XDebug Proxy - -Create an IP Alias : - -```sh -sudo ifconfig en0 alias 10.254.254.254 255.255.255.0 -``` - -![Xdebug Proxy](images/ps-mac-php-xdebug-proxy.png) - -To delete an IP Alias : - -```sh -sudo ifconfig en0 -alias 10.254.254.254 -``` - -### XDebug Demo - -![XDebug Demo](images/ps-mac-php-xdebug-demo.png) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b30cd5728..0572bc84d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,47 +1,55 @@ -version: '3' services: - web: - image: nginx:alpine + nginx: + image: nginx:${NGINX_VERSION} + container_name: ${APP_SLUG}_nginx + hostname: ${APP_SLUG}_nginx volumes: - "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf" - - "./etc/ssl:/etc/ssl" - "./web:/var/www/html" - "./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template" + - "/etc/letsencrypt:/etc/letsencrypt:ro" + - "/tmp/acme-challenge:/tmp/acme-challenge" ports: - - "8000:80" - - "3000:443" + - "80:80" + - "443:443" + links: + - php-fpm environment: - NGINX_HOST=${NGINX_HOST} command: /bin/sh -c "envsubst '$$NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" restart: always + networks: + - ${APP_SLUG}_network depends_on: - - php - - mysqldb - php: - image: nanoninja/php-fpm:${PHP_VERSION} + - php-fpm + - mysql + letsencrypt: + container_name: certbot + image: certbot/certbot + command: sh -c "certbot certonly --webroot -w /tmp/acme-challenge/ -d ${NGINX_HOST} --text --agree-tos --email ${CERT_EMAIL} --rsa-key-size 4096 --verbose --keep-until-expiring --preferred-chall> + entrypoint: "" + volumes: + - "/etc/letsencrypt:/etc/letsencrypt" + - "/tmp/acme-challenge:/tmp/acme-challenge" + environment: + - TERM=xterm + php-fpm: + image: php:${PHP_VERSION} + container_name: ${APP_SLUG}_php-fpm + hostname: ${APP_SLUG}_php-fpm restart: always volumes: - "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini" - "./web:/var/www/html" - composer: - image: "composer" - volumes: - - "./web/app:/app" - command: install - myadmin: - image: phpmyadmin/phpmyadmin - container_name: phpmyadmin - ports: - - "8080:80" - environment: - - PMA_ARBITRARY=1 - - PMA_HOST=${MYSQL_HOST} - restart: always - depends_on: - - mysqldb - mysqldb: + cap_add: + - SYS_NICE + - DAC_READ_SEARCH + networks: + - ${APP_SLUG}_network + mysql: image: mysql:${MYSQL_VERSION} - container_name: ${MYSQL_HOST} + container_name: ${APP_SLUG}_mysql + hostname: ${APP_SLUG}_mysql restart: always env_file: - ".env" @@ -53,4 +61,9 @@ services: ports: - "8989:3306" volumes: - - "./data/db/mysql:/var/lib/mysql" \ No newline at end of file + - "./data/db/mysql:/var/lib/mysql" + networks: + - ${APP_SLUG}_network +networks: + [REPLACE_WITH_SLUG]_network: + external: true diff --git a/etc/nginx/default.template.conf b/etc/nginx/default.template.conf index 3d76e28d9..d8fdce424 100644 --- a/etc/nginx/default.template.conf +++ b/etc/nginx/default.template.conf @@ -20,7 +20,10 @@ server { if (-d "$document_root$virtualdir") { set $realdir "${virtualdir}"; } - + location /.well-known/acme-challenge/ { + allow all; + root /tmp/acme-challenge; + } location / { try_files $uri $uri/ $realdir/index.php?$args; } @@ -41,8 +44,8 @@ server { # listen 443 ssl; # fastcgi_param HTTPS on; -# ssl_certificate /etc/ssl/server.pem; -# ssl_certificate_key /etc/ssl/server.key; +# ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; +# ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem; # ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; # index index.php index.html; diff --git a/etc/php/php.ini b/etc/php/php.ini index 4f47c01f7..5db327bac 100644 --- a/etc/php/php.ini +++ b/etc/php/php.ini @@ -3,27 +3,12 @@ ;[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone -;date.timezone = +date.timezone = Europe/Moscow ; Error handling ;display_errors = Off -; Xdebug -; See https://xdebug.org/docs/all_settings - -;PHPStorm -[Xdebug] -xdebug.remote_enable=1 -xdebug.idekey=PHPSTORM -xdebug.profiler_enable=0 -xdebug.max_nesting_level=700 -xdebug.remote_host=192.168.0.1 # your ip -xdebug.remote_port=9000 - -;Netbeans -;[Xdebug] -;xdebug.remote_enable=1 -;xdebug.remote_handler=dbgp -;xdebug.remote_mode=req -;xdebug.remote_host=192.168.0.1 # your ip -;xdebug.remote_port=9000 \ No newline at end of file +upload_max_filesize = 500 +Mmax_file_uploads = 20 +post_max_size = 500 +Mmemory_limit = 4096 diff --git a/web/app/composer.json.dist b/web/app/composer.json.dist deleted file mode 100644 index b4850f712..000000000 --- a/web/app/composer.json.dist +++ /dev/null @@ -1,22 +0,0 @@ -{ - "require": { - "symfony/yaml": "^5.1" - }, - "require-dev": { - "phpmd/phpmd": "@stable", - "phpunit/phpunit": "^9.0", - "squizlabs/php_codesniffer": "3.5.*" - }, - "autoload": { - "psr-4": { - "App\\Acme\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "AppTest\\Acme\\": "test/" - } - }, - "minimum-stability": "stable", - "prefer-stable": true -} diff --git a/web/app/phpunit.xml.dist b/web/app/phpunit.xml.dist deleted file mode 100644 index 7cd9c11cf..000000000 --- a/web/app/phpunit.xml.dist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - ./test/ - - - - - - ./src - - ./vendor - - - - - - - - - - - - - diff --git a/web/app/src/Foo.php b/web/app/src/Foo.php deleted file mode 100644 index f982f487f..000000000 --- a/web/app/src/Foo.php +++ /dev/null @@ -1,21 +0,0 @@ -assertEquals($foo->getName(), 'Nginx PHP MySQL'); - } -} diff --git a/web/app/test/bootstrap.php b/web/app/test/bootstrap.php deleted file mode 100644 index 5106c0e1c..000000000 --- a/web/app/test/bootstrap.php +++ /dev/null @@ -1,8 +0,0 @@ - + - Docker <?php echo $foo->getName(); ?> + Docker -

Docker getName(); ?>

+

Docker