├── .assets └── bootstrap.php ├── .docker ├── README.md ├── mysql.env.development ├── nginx │ └── default.conf ├── php.env.development └── php │ ├── development │ ├── conf.d │ │ └── 20-overrides.ini.development │ └── php.ini │ ├── docker-entrypoint.sh │ ├── docker-healthcheck.sh │ └── production │ └── php.ini ├── .dockerignore ├── .editorconfig ├── .github ├── PULL_REQUEST_TEMPLATE └── workflows │ ├── build.yml │ └── image.yml ├── .gitignore ├── .kube ├── README.md ├── mysql-secret.yaml ├── mysql.yaml ├── namespace.yaml ├── php-ngnix.yaml └── php-secret.yaml ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── app └── .gitkeep └── docker-compose.yml /.assets/bootstrap.php: -------------------------------------------------------------------------------- 1 | parse() 69 | ->putenv() 70 | ->toEnv() 71 | ->toServer(); 72 | } 73 | 74 | /* 75 | * Read configuration file and inject configuration into various 76 | * CakePHP classes. 77 | * 78 | * By default there is only one configuration file. It is often a good 79 | * idea to create multiple configuration files, and separate the configuration 80 | * that changes from configuration that does not. This makes deployment simpler. 81 | */ 82 | try { 83 | Configure::config('default', new PhpConfig()); 84 | Configure::load('app', 'default', false); 85 | } catch (\Exception $e) { 86 | exit($e->getMessage() . "\n"); 87 | } 88 | 89 | /* 90 | * Load an environment local configuration file to provide overrides to your configuration. 91 | * Notice: For security reasons app_local.php **should not** be included in your git repo. 92 | */ 93 | if (file_exists(CONFIG . 'app_local.php')) { 94 | Configure::load('app_local', 'default'); 95 | } 96 | 97 | /* 98 | * When debug = true the metadata cache should only last 99 | * for a short time. 100 | */ 101 | if (Configure::read('debug')) { 102 | Configure::write('Cache._cake_model_.duration', '+2 minutes'); 103 | Configure::write('Cache._cake_core_.duration', '+2 minutes'); 104 | // disable router cache during development 105 | Configure::write('Cache._cake_routes_.duration', '+2 seconds'); 106 | } 107 | 108 | /* 109 | * Set the default server timezone. Using UTC makes time calculations / conversions easier. 110 | * Check http://php.net/manual/en/timezones.php for list of valid timezone strings. 111 | */ 112 | date_default_timezone_set(Configure::read('App.defaultTimezone')); 113 | 114 | /* 115 | * Configure the mbstring extension to use the correct encoding. 116 | */ 117 | mb_internal_encoding(Configure::read('App.encoding')); 118 | 119 | /* 120 | * Set the default locale. This controls how dates, number and currency is 121 | * formatted and sets the default language to use for translations. 122 | */ 123 | ini_set('intl.default_locale', Configure::read('App.defaultLocale')); 124 | 125 | /* 126 | * Register application error and exception handlers. 127 | */ 128 | (new ErrorTrap(Configure::read('Error')))->register(); 129 | (new ExceptionTrap(Configure::read('Error')))->register(); 130 | 131 | /* 132 | * Include the CLI bootstrap overrides. 133 | */ 134 | if (PHP_SAPI === 'cli') { 135 | require __DIR__ . '/bootstrap_cli.php'; 136 | } 137 | 138 | 139 | /* 140 | * Set the full base URL. 141 | * This URL is used as the base of all absolute links. 142 | */ 143 | $fullBaseUrl = Configure::read('App.fullBaseUrl'); 144 | if (!$fullBaseUrl) { 145 | $s = null; 146 | if (env('HTTPS')) { 147 | $s = 's'; 148 | } 149 | 150 | $httpHost = env('HTTP_HOST'); 151 | if (isset($httpHost)) { 152 | $fullBaseUrl = 'http' . $s . '://' . $httpHost; 153 | } 154 | unset($httpHost, $s); 155 | } 156 | if ($fullBaseUrl) { 157 | Router::fullBaseUrl($fullBaseUrl); 158 | } 159 | unset($fullBaseUrl); 160 | 161 | Cache::setConfig(Configure::consume('Cache')); 162 | ConnectionManager::setConfig(Configure::consume('Datasources')); 163 | TransportFactory::setConfig(Configure::consume('EmailTransport')); 164 | Mailer::setConfig(Configure::consume('Email')); 165 | Log::setConfig(Configure::consume('Log')); 166 | Security::setSalt(Configure::consume('Security.salt')); 167 | 168 | /* 169 | * Setup detectors for mobile and tablet. 170 | */ 171 | ServerRequest::addDetector('mobile', function ($request) { 172 | $detector = new \Detection\MobileDetect(); 173 | 174 | return $detector->isMobile(); 175 | }); 176 | ServerRequest::addDetector('tablet', function ($request) { 177 | $detector = new \Detection\MobileDetect(); 178 | 179 | return $detector->isTablet(); 180 | }); 181 | 182 | /* 183 | * You can set whether the ORM uses immutable or mutable Time types. 184 | * The default changed in 4.0 to immutable types. You can uncomment 185 | * below to switch back to mutable types. 186 | * 187 | * You can enable default locale format parsing by adding calls 188 | * to `useLocaleParser()`. This enables the automatic conversion of 189 | * locale specific date formats. For details see 190 | * @link https://book.cakephp.org/4/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data 191 | */ 192 | // TypeFactory::build('time') 193 | // ->useMutable(); 194 | // TypeFactory::build('date') 195 | // ->useMutable(); 196 | // TypeFactory::build('datetime') 197 | // ->useMutable(); 198 | // TypeFactory::build('timestamp') 199 | // ->useMutable(); 200 | // TypeFactory::build('datetimefractional') 201 | // ->useMutable(); 202 | // TypeFactory::build('timestampfractional') 203 | // ->useMutable(); 204 | // TypeFactory::build('datetimetimezone') 205 | // ->useMutable(); 206 | // TypeFactory::build('timestamptimezone') 207 | // ->useMutable(); 208 | 209 | /* 210 | * Custom Inflector rules, can be set to correctly pluralize or singularize 211 | * table, model, controller names or whatever other string is passed to the 212 | * inflection functions. 213 | */ 214 | //Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']); 215 | //Inflector::rules('irregular', ['red' => 'redlings']); 216 | //Inflector::rules('uninflected', ['dontinflectme']); 217 | -------------------------------------------------------------------------------- /.docker/README.md: -------------------------------------------------------------------------------- 1 | # 🐋 Docker 2 | 3 | It's expected that you will use your own Dockerfile for production. 4 | 5 | ## NGINX 6 | 7 | See [nginx](nginx) directory for configurations. These get loaded as a docker-compose volume. 8 | 9 | ## MySQL 10 | 11 | Environment variables are loaded by docker-compose from [mysql.env.development](mysql.env.development). 12 | 13 | ## PHP 14 | 15 | See [php](php) for PHP related configuration files, healthcheck, and entrypoint. 16 | 17 | The [php/development/conf.d/20-overrides.ini.development](php/development/conf.d/20-overrides.ini.development) file is 18 | used a base config to populate the git ignored 19 | [php/development/conf.d/20-overrides.ini](php/development/conf.d/20-overrides.ini). The latter is actually loaded 20 | by PHP. This is to allow for easily toggling xdebug on and off via the Makefile. 21 | 22 | Environment variables are loaded by docker-compose from [php.env.development](php.env.development). 23 | -------------------------------------------------------------------------------- /.docker/mysql.env.development: -------------------------------------------------------------------------------- 1 | # 2 | # MySQL 3 | # 4 | MYSQL_ROOT_PASSWORD=root 5 | MYSQL_DATABASE=cakephp 6 | MYSQL_USER=cakephp 7 | MYSQL_PASSWORD=cakephp -------------------------------------------------------------------------------- /.docker/nginx/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | 4 | root /srv/app/webroot/; 5 | index index.php; 6 | 7 | location / { 8 | try_files $uri $uri/ /index.php?$args; 9 | } 10 | 11 | location ~ \.php$ { 12 | try_files $uri =404; 13 | include fastcgi_params; 14 | fastcgi_pass php:9000; 15 | fastcgi_index index.php; 16 | fastcgi_intercept_errors on; 17 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.docker/php.env.development: -------------------------------------------------------------------------------- 1 | # 2 | # cakephp 3 | # 4 | DATABASE_URL=mysql://root:root@db/cakephp?encoding=utf8&timezone=UTC&cacheMetadata=true"eIdentifiers=false&persistent=false 5 | -------------------------------------------------------------------------------- /.docker/php/development/conf.d/20-overrides.ini.development: -------------------------------------------------------------------------------- 1 | [xdebug] 2 | xdebug.mode=off -------------------------------------------------------------------------------- /.docker/php/development/php.ini: -------------------------------------------------------------------------------- 1 | ; 2 | ; Development 3 | ; 4 | extension=intl.so 5 | extension=pdo_mysql.so 6 | extension=sodium 7 | extension=zip.so 8 | zend_extension=opcache.so 9 | zend_extension=xdebug 10 | 11 | [php] 12 | session.auto_start = Off 13 | short_open_tag = Off 14 | opcache.interned_strings_buffer = 16 15 | opcache.max_accelerated_files = 20000 16 | opcache.memory_consumption = 256 17 | realpath_cache_size = 4096K 18 | realpath_cache_ttl = 600 19 | expose_php = on 20 | 21 | [xdebug] 22 | xdebug.discover_client_host = true 23 | ;xdebug.client_host = host.docker.internal 24 | xdebug.client_host = 172.17.0.1 25 | xdebug.start_with_request = yes 26 | -------------------------------------------------------------------------------- /.docker/php/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # first arg is `-f` or `--some-option` 5 | if [ "${1#-}" != "$1" ]; then 6 | set -- php-fpm "$@" 7 | fi 8 | 9 | if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/cakephp' ]; then 10 | 11 | # The first time volumes are mounted, the project needs to be recreated 12 | if [ ! -f composer.json ]; then 13 | 14 | if [ -f .gitkeep ]; then 15 | rm .gitkeep # create project fails if directory is not empty 16 | fi 17 | 18 | COMPOSER_MEMORY_LIMIT=-1 19 | composer create-project --prefer-dist --no-interaction cakephp/app:^5.0 . 20 | rm -rf .github 21 | cp config/.env.example config/.env 22 | cp config/app_local.example.php config/app_local.php 23 | cp ../.assets/bootstrap.php config/bootstrap.php 24 | 25 | sed -i '/export APP_NAME/c\export APP_NAME="cakephp"' config/.env 26 | 27 | salt=$(openssl rand -base64 32) 28 | sed -i '/export SECURITY_SALT/c\export SECURITY_SALT="'$salt'"' config/.env 29 | 30 | touch .gitkeep 31 | fi 32 | 33 | echo "ENV: $APP_ENV" 34 | if [ "$APP_ENV" != 'prod' ]; then 35 | composer install --prefer-dist --no-interaction 36 | fi 37 | 38 | mkdir -p logs tmp 39 | 40 | # Set ACLs for Linux users 41 | echo "HOST OS: $HOST_OS" 42 | if [[ $HOST_OS == *"Linux"* ]]; then 43 | echo "Setting ACLs..." 44 | setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX logs 45 | setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX tmp 46 | setfacl -R -m g:nginx:rwX /srv/app 47 | fi 48 | 49 | echo "setting ownership..." 50 | chown -R cakephp:www-data . 51 | 52 | echo "setting permissions..." 53 | chmod 774 -R . 54 | 55 | echo "waiting for fpm..." 56 | fi 57 | 58 | exec docker-php-entrypoint "$@" 59 | -------------------------------------------------------------------------------- /.docker/php/docker-healthcheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | export SCRIPT_NAME=/ping 5 | export SCRIPT_FILENAME=/ping 6 | export REQUEST_METHOD=GET 7 | 8 | if curl -v -o /dev/null http://localhost:8080; then 9 | exit 0 10 | fi 11 | 12 | exit 1 -------------------------------------------------------------------------------- /.docker/php/production/php.ini: -------------------------------------------------------------------------------- 1 | ; 2 | ; Production 3 | ; 4 | extension=intl.so 5 | extension=pdo_mysql.so 6 | extension=sodium 7 | extension=zip.so 8 | zend_extension=opcache.so 9 | 10 | [php] 11 | session.auto_start = Off 12 | short_open_tag = Off 13 | opcache.interned_strings_buffer = 16 14 | opcache.max_accelerated_files = 20000 15 | opcache.memory_consumption = 256 16 | realpath_cache_size = 4096K 17 | realpath_cache_ttl = 600 18 | expose_php = off 19 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | app/vendor/ 2 | app/logs/ 3 | app/tmp/ 4 | app/config/.env 5 | app/config/app_local.php 6 | app/.git 7 | app/.cache 8 | app/.editorconfig 9 | app/.gitattributes 10 | app/.gitignore 11 | app/.gitkeep 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at https://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 4 9 | end_of_line = lf 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | [*.bat] 14 | end_of_line = crlf 15 | 16 | [*.yml] 17 | indent_size = 2 18 | 19 | [*.yaml] 20 | indent_size = 2 21 | 22 | [*.twig] 23 | insert_final_newline = false 24 | 25 | [Makefile] 26 | indent_style = tab 27 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE: -------------------------------------------------------------------------------- 1 | Issue: _link_or_issue_number_here 2 | 3 | #### Description 4 | 5 | _brief_description_here_ 6 | 7 | #### Testing 8 | 9 | _steps_to_test_code_here_ -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | build: 7 | name: Docker Build 8 | runs-on: ubuntu-22.04 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | - name: Env Files 13 | run: | 14 | cp .docker/php.env.development .docker/php.env 15 | cp .docker/mysql.env.development .docker/mysql.env 16 | - name: Pull images 17 | run: docker compose pull 18 | - name: Build 19 | run: docker compose build --build-arg UID=$(id -u) --build-arg ENV=dev 20 | - name: Start 21 | run: docker compose up -d 22 | - name: Wait for services 23 | run: sleep 10 24 | - name: Check CakePHP Welcome Page 25 | run: curl -f -v -o /dev/null http://localhost:8080 26 | - name: Check NGINX Files 27 | run: curl -f -v -o /dev/null http://localhost:8080/css/home.css 28 | -------------------------------------------------------------------------------- /.github/workflows/image.yml: -------------------------------------------------------------------------------- 1 | name: Image 2 | 3 | #on: 4 | # create: 5 | # tags: 6 | # - "v*.*.*" 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v2 16 | 17 | - name: Prepare 18 | id: prep 19 | run: | 20 | DOCKER_IMAGE=cnizzardini/cakephp-docker 21 | VERSION=edge 22 | if [[ $GITHUB_REF == refs/tags/* ]]; then 23 | VERSION=${GITHUB_REF#refs/tags/v} 24 | fi 25 | TAGS="${DOCKER_IMAGE}:${VERSION}" 26 | if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then 27 | TAGS="$TAGS,${DOCKER_IMAGE}:4.4-latest" 28 | fi 29 | echo ::set-output name=tags::${TAGS} 30 | - 31 | name: Login to DockerHub 32 | uses: docker/login-action@v1 33 | with: 34 | username: ${{ secrets.DOCKERHUB_USERNAME }} 35 | password: ${{ secrets.DOCKERHUB_PASSWORD }} 36 | - 37 | name: Build and push 38 | id: docker_build 39 | uses: docker/build-push-action@v2 40 | with: 41 | context: ./ 42 | push: ${{ github.event_name != 'pull_request' }} 43 | tags: ${{ steps.prep.outputs.tags }} 44 | build-args: ENV=prod 45 | - 46 | name: Image digest 47 | run: echo ${{ steps.docker_build.outputs.digest }} 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # remove the following: 2 | app/* 3 | !app/.gitkeep 4 | # end removal 5 | 6 | # OS generated files # 7 | ###################### 8 | .DS_Store 9 | .DS_Store? 10 | ._* 11 | .Spotlight-V100 12 | .Trashes 13 | Icon? 14 | ehthumbs.db 15 | Thumbs.db 16 | .directory 17 | 18 | # Tool specific files # 19 | ####################### 20 | # PHPUnit 21 | .phpunit.result.cache 22 | # vim 23 | *~ 24 | *.swp 25 | *.swo 26 | # sublime text & textmate 27 | *.sublime-* 28 | *.stTheme.cache 29 | *.tmlanguage.cache 30 | *.tmPreferences.cache 31 | # Eclipse 32 | .settings/* 33 | # JetBrains, aka PHPStorm, IntelliJ IDEA 34 | .idea/* 35 | # NetBeans 36 | nbproject/* 37 | # Visual Studio Code 38 | .vscode 39 | # Sass preprocessor 40 | .sass-cache/ 41 | 42 | # project files # 43 | ###################### 44 | .docker/php/development/conf.d/*.ini 45 | -------------------------------------------------------------------------------- /.kube/README.md: -------------------------------------------------------------------------------- 1 | # ☸ Kubernetes 2 | 3 | This is provided as a starter/example setup. You can run kubernetes locally with an orchestration tool such as 4 | [minikube](https://minikube.sigs.k8s.io/docs/) and [kubectl](https://kubernetes.io/docs/tasks/tools/). 5 | 6 | Starting minikube: 7 | 8 | ```console 9 | minikube start 10 | ``` 11 | 12 | Apply configs: 13 | 14 | ```console 15 | kubectl apply -f .kube/namespace.yaml 16 | kubectl apply -f .kube/mysql-secret.yaml 17 | kubectl apply -f .kube/php-secret.yaml 18 | kubectl apply -f .kube/. 19 | ``` 20 | 21 | Minikube dashboard: 22 | 23 | ```console 24 | minikube dashboard --url 25 | ``` 26 | 27 | Create services: 28 | 29 | ```console 30 | minikube service nginx -n cakephp-docker 31 | minikube service mysql -n cakephp-docker 32 | ``` 33 | 34 | Browse to the given nginx url: 35 | 36 | ```console 37 | minikube service list 38 | ``` 39 | 40 | MySQL: 41 | 42 | ```console 43 | mysql -u cakephp -h 192.168.49.2 -p --port 32089 44 | ``` 45 | 46 | > Password is `cakephp` 47 | 48 | Docker build / push commands: 49 | 50 | ```console 51 | docker build . -t cnizzardini/cakephp-docker:latest 52 | docker push cnizzardini/cakephp-docker:latest 53 | ``` 54 | 55 | -------------------------------------------------------------------------------- /.kube/mysql-secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: mysql-secret 5 | namespace: cakephp-docker 6 | type: Opaque 7 | data: 8 | # root 9 | mysql-root-password: cm9vdA== 10 | # cakephp 11 | mysql-user: Y2FrZXBocA== 12 | mysql-password: Y2FrZXBocA== 13 | -------------------------------------------------------------------------------- /.kube/mysql.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: mysql-config 5 | namespace: cakephp-docker 6 | labels: 7 | app: mysql 8 | data: 9 | default_auth: | 10 | [mysqld] 11 | default_authentication_plugin= mysql_native_password 12 | sql-mode="" 13 | 14 | --- 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: mysql-deployment 19 | namespace: cakephp-docker 20 | labels: 21 | app: mysql 22 | spec: 23 | replicas: 1 24 | selector: 25 | matchLabels: 26 | app: mysql 27 | template: 28 | metadata: 29 | labels: 30 | app: mysql 31 | spec: 32 | containers: 33 | - name: mysql 34 | image: library/mysql:8 35 | ports: 36 | - containerPort: 3306 37 | env: 38 | - name: MYSQL_DATABASE 39 | value: cakephp 40 | - name: MYSQL_ROOT_PASSWORD 41 | valueFrom: 42 | secretKeyRef: 43 | name: mysql-secret 44 | key: mysql-root-password 45 | - name: MYSQL_USER 46 | valueFrom: 47 | secretKeyRef: 48 | name: mysql-secret 49 | key: mysql-user 50 | - name: MYSQL_PASSWORD 51 | valueFrom: 52 | secretKeyRef: 53 | name: mysql-secret 54 | key: mysql-password 55 | volumeMounts: 56 | - name: mysql-config-volume 57 | mountPath: /etc/mysql/conf.d/default_auth.cnf 58 | subPath: default_auth 59 | volumes: 60 | - name: mysql-config-volume 61 | configMap: 62 | name: mysql-config 63 | - name: mysql 64 | persistentVolumeClaim: 65 | claimName: mysql-pv-claim 66 | --- 67 | apiVersion: v1 68 | kind: PersistentVolumeClaim 69 | metadata: 70 | name: mysql-pv-claim 71 | namespace: cakephp-docker 72 | labels: 73 | app: mysql 74 | spec: 75 | accessModes: 76 | - ReadWriteOnce 77 | resources: 78 | requests: 79 | storage: 1Gi 80 | --- 81 | apiVersion: v1 82 | kind: Service 83 | metadata: 84 | name: mysql 85 | namespace: cakephp-docker 86 | spec: 87 | type: NodePort 88 | selector: 89 | app: mysql 90 | ports: 91 | - protocol: TCP 92 | port: 3306 93 | targetPort: 3306 94 | nodePort: 32089 95 | -------------------------------------------------------------------------------- /.kube/namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: cakephp-docker 5 | -------------------------------------------------------------------------------- /.kube/php-ngnix.yaml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: php-ini 5 | namespace: cakephp-docker 6 | labels: 7 | app: php 8 | data: 9 | php.ini: | 10 | extension=intl.so 11 | extension=pdo_mysql.so 12 | extension=sodium 13 | extension=zip.so 14 | zend_extension=opcache.so 15 | 16 | [php] 17 | session.auto_start = Off 18 | short_open_tag = Off 19 | opcache.interned_strings_buffer = 16 20 | opcache.max_accelerated_files = 20000 21 | opcache.memory_consumption = 256 22 | realpath_cache_size = 4096K 23 | realpath_cache_ttl = 600 24 | expose_php = off 25 | --- 26 | kind: ConfigMap 27 | apiVersion: v1 28 | metadata: 29 | name: nginx-conf 30 | namespace: cakephp-docker 31 | labels: 32 | app: nginx 33 | data: 34 | default.conf: |- 35 | server { 36 | listen 80; 37 | 38 | root /application/webroot/; 39 | index index.php; 40 | 41 | location / { 42 | try_files $uri /index.php?$args; 43 | } 44 | 45 | location ~ \.php$ { 46 | fastcgi_pass 127.0.0.1:9000; 47 | fastcgi_index index.php; 48 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 49 | fastcgi_buffers 16 16k; 50 | fastcgi_buffer_size 32k; 51 | include fastcgi_params; 52 | } 53 | } 54 | --- 55 | apiVersion: apps/v1 56 | kind: Deployment 57 | metadata: 58 | name: php-nginx-deployment 59 | namespace: cakephp-docker 60 | labels: 61 | app: php-nginx 62 | spec: 63 | replicas: 1 64 | selector: 65 | matchLabels: 66 | app: php-nginx 67 | template: 68 | metadata: 69 | labels: 70 | app: php-nginx 71 | spec: 72 | containers: 73 | - name: php 74 | image: cnizzardini/cakephp-docker:latest 75 | imagePullPolicy: Always 76 | ports: 77 | - containerPort: 9000 78 | env: 79 | - name: DATABASE_URL 80 | valueFrom: 81 | secretKeyRef: 82 | name: php-secret 83 | key: database-url 84 | - name: SECURITY_SALT 85 | valueFrom: 86 | secretKeyRef: 87 | name: php-secret 88 | key: cakephp-salt 89 | - name: DEBUG 90 | value: 'false' 91 | volumeMounts: 92 | - name: php-ini 93 | mountPath: /usr/local/etc/php/conf.d 94 | - name: application 95 | mountPath: /application 96 | lifecycle: 97 | postStart: 98 | exec: 99 | command: 100 | - "/bin/sh" 101 | - "-c" 102 | - > 103 | cp -r /srv/app/. /application/. 104 | 105 | - name: nginx 106 | image: nginx:1.19-alpine 107 | ports: 108 | - containerPort: 80 109 | volumeMounts: 110 | - name: nginx-conf 111 | mountPath: /etc/nginx/conf.d 112 | - name: application 113 | mountPath: /application 114 | lifecycle: 115 | postStart: 116 | exec: 117 | command: 118 | - "/bin/sh" 119 | - "-c" 120 | - > 121 | chmod 775 -R /application && 122 | chmod 777 -R /application/logs && 123 | chmod 777 -R /application/tmp 124 | 125 | volumes: 126 | - name: php-ini 127 | configMap: 128 | name: php-ini 129 | - name: nginx-conf 130 | configMap: 131 | name: nginx-conf 132 | items: 133 | - key: default.conf 134 | path: default.conf 135 | - name: application 136 | emptyDir: {} 137 | --- 138 | apiVersion: v1 139 | kind: Service 140 | metadata: 141 | name: nginx 142 | namespace: cakephp-docker 143 | labels: 144 | app: nginx 145 | spec: 146 | selector: 147 | app: php-nginx 148 | type: LoadBalancer 149 | ports: 150 | - protocol: TCP 151 | port: 80 152 | targetPort: 80 153 | nodePort: 30002 154 | --- 155 | apiVersion: v1 156 | kind: Service 157 | metadata: 158 | name: php 159 | namespace: cakephp-docker 160 | labels: 161 | app: php 162 | spec: 163 | selector: 164 | app: php-nginx 165 | ports: 166 | - protocol: TCP 167 | port: 9000 168 | targetPort: 9000 169 | -------------------------------------------------------------------------------- /.kube/php-secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: php-secret 5 | namespace: cakephp-docker 6 | type: Opaque 7 | data: 8 | # mysql://cakephp:cakephp@192.168.49.2:32089/cakephp?encoding=utf8&timezone=UTC&cacheMetadata=true"eIdentifiers=false&persistent=false 9 | database-url: bXlzcWw6Ly9jYWtlcGhwOmNha2VwaHBAMTkyLjE2OC40OS4yOjMyMDg5L2Nha2VwaHA/ZW5jb2Rpbmc9dXRmOCZ0aW1lem9uZT1VVEMmY2FjaGVNZXRhZGF0YT10cnVlJnF1b3RlSWRlbnRpZmllcnM9ZmFsc2UmcGVyc2lzdGVudD1mYWxzZQ== 10 | cakephp-salt: MzJ0RkxRb3BGdVNpbThTbVpzaW93cXM5dlVVZHJ4YzQK 11 | 12 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # container 3 | # @see https://hub.docker.com/repository/docker/cnizzardini/php-fpm-alpine 4 | # @see https://github.com/cnizzardini/php-fpm-alpine/tree/php-8.3 5 | FROM cnizzardini/php-fpm-alpine:8.3-latest AS cakephp_php 6 | 7 | ARG ENV=prod 8 | ARG UID=1000 9 | ARG HOST_OS=Linux 10 | ENV APP_ENV=$ENV 11 | ENV HOST_OS=$HOST_OS 12 | 13 | # 14 | # dev/test depdencies 15 | # 16 | RUN if [[ "$ENV" != "prod" ]]; then \ 17 | apk add git \ 18 | && apk add --no-cache --virtual .php-deps file re2c autoconf make zlib zlib-dev g++ curl linux-headers \ 19 | && pecl install xdebug \ 20 | && docker-php-ext-enable xdebug \ 21 | && apk del -f .php-deps; \ 22 | fi 23 | 24 | # 25 | # application 26 | # 27 | COPY .docker/php/docker-healthcheck.sh /usr/local/bin/docker-healthcheck 28 | RUN chmod +x /usr/local/bin/docker-healthcheck 29 | HEALTHCHECK --interval=10s --timeout=3s --retries=3 CMD ["docker-healthcheck"] 30 | 31 | COPY .docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint 32 | RUN chmod +x /usr/local/bin/docker-entrypoint 33 | 34 | COPY .assets /srv/.assets 35 | 36 | WORKDIR /srv/app 37 | 38 | RUN adduser --disabled-password --gecos '' -u $UID cakephp; 39 | RUN addgroup -g 101 nginx 40 | RUN addgroup cakephp nginx 41 | RUN addgroup cakephp www-data 42 | 43 | COPY --from=composer /usr/bin/composer /usr/bin/composer 44 | 45 | COPY app . 46 | 47 | RUN if [[ "$ENV" = "prod" ]]; then \ 48 | composer install --prefer-dist --no-interaction --no-dev; \ 49 | fi 50 | 51 | ENTRYPOINT ["docker-entrypoint"] 52 | CMD ["php-fpm"] 53 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2021 Chris Nizzardini 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL := /bin/bash # set shell based on host os, use /bin/zsh for mac 2 | .DEFAULT_GOAL := help 3 | 4 | # 5 | # define standard colors 6 | # 7 | ifneq (,$(findstring xterm,${TERM})) 8 | BLACK := $(shell tput -Txterm setaf 0) 9 | RED := $(shell tput -Txterm setaf 1) 10 | GREEN := $(shell tput -Txterm setaf 2) 11 | YELLOW := $(shell tput -Txterm setaf 3) 12 | LIGHTPURPLE := $(shell tput -Txterm setaf 4) 13 | PURPLE := $(shell tput -Txterm setaf 5) 14 | BLUE := $(shell tput -Txterm setaf 6) 15 | WHITE := $(shell tput -Txterm setaf 7) 16 | RESET := $(shell tput -Txterm sgr0) 17 | else 18 | BLACK := "" 19 | RED := "" 20 | GREEN := "" 21 | YELLOW := "" 22 | LIGHTPURPLE := "" 23 | PURPLE := "" 24 | BLUE := "" 25 | WHITE := "" 26 | RESET := "" 27 | endif 28 | 29 | # 30 | # vars 31 | # 32 | DOCKER_COMPOSE := "docker-compose.yml" 33 | PHP := $(shell docker-compose ps -q php) 34 | PHP_DEV_PATH := ".docker/php/development" 35 | 36 | # 37 | # unicode icons 38 | # 39 | CAKEPHP_ICO := ' \U1F370 ' 40 | DOCKER_ICO := ' \U1F40B ' 41 | SHELL_ICO := ' \U1F41A ' 42 | MYSQL_ICO := ' \U1F42C ' 43 | XDEBUG_ICO := ' \U1F41E ' 44 | CANCEL_ICO := ' \U1F515 ' 45 | KUBE_ICO := ' \U2699 ' 46 | COMP_ICO := ' \U1F3B5 ' 47 | 48 | # 49 | # titles and separators 50 | # 51 | S := \U203A 52 | E := $(RESET)\n 53 | CMD := \n $(PURPLE) 54 | GOOD := $(GREEN) 55 | INFO := $(BLUE) 56 | WARN := $(YELLOW) 57 | 58 | # 59 | # cmds 60 | # 61 | DC_START := docker-compose start 62 | DC_STOP := docker-compose stop 63 | DC_UP := docker-compose up 64 | DC_DOWN := docker-compose down 65 | PHP_SH := docker exec -it --user cakephp $(PHP) sh 66 | DB_SH := docker exec -it $(shell docker-compose ps -q db) sh 67 | MYSQL_SH := mysql -u root -h 0.0.0.0 -p --port 3307 68 | WEB_SH := docker exec -it $(shell docker-compose ps -q web) sh 69 | COMP_INSTALL := docker exec $(PHP) composer install --no-interaction --no-plugins --no-scripts --prefer-dist 70 | COMP_TEST := docker exec $(PHP) composer test 71 | COMP_CHECK := docker exec $(PHP) composer check 72 | 73 | # 74 | # help 75 | # 76 | help: 77 | @printf "\n" 78 | @printf $(CAKEPHP_ICO) && printf "$(RED) CakePHP Docker (unofficial) $(S)" 79 | @printf "$(LIGHTPURPLE) https://github.com/cnizzardini/cakephp-docker $(E)\n" 80 | @printf " command \t\t description $(E)" 81 | @printf " ------- \t\t ----------- $(E)" 82 | @printf "$(INFO) make init $(RESET)\t\t build and bring up containers $(E)" 83 | @printf "$(INFO) make init.nocache $(RESET)\t build and bring up containers w/o cache $(E)" 84 | @printf "\n" 85 | @printf "$(INFO) make start $(RESET)\t\t start containers $(E)" 86 | @printf "$(INFO) make stop $(RESET)\t\t stop containers $(E)" 87 | @printf "$(INFO) make up $(RESET)\t\t bring up containers $(E)" 88 | @printf "$(INFO) make down $(RESET)\t\t stop/remove containers, networks, and volumes $(E)" 89 | @printf "$(INFO) make restart $(RESET)\t\t restart containers $(E)" 90 | @printf "$(INFO) make php.restart $(RESET)\t restart php container $(E)" 91 | @printf "\n" 92 | @printf "$(INFO) make php.sh $(RESET)\t\t php container shell $(E)" 93 | @printf "$(INFO) make db.sh $(RESET)\t\t db container shell $(E)" 94 | @printf "$(INFO) make web.sh $(RESET)\t\t web container shell $(E)" 95 | @printf "$(INFO) make db.mysql $(RESET)\t\t mysql console $(E)" 96 | @printf "\n" 97 | @printf "$(INFO) make xdebug.on $(RESET)\t enable xdebug $(E)" 98 | @printf "$(INFO) make xdebug.off $(RESET)\t disable xdebug $(E)" 99 | @printf "$(INFO) make composer.install $(RESET)\t install composer dependencies $(E)" 100 | @printf "$(INFO) make composer.test $(RESET)\t run phpunit test suite $(E)" 101 | @printf "$(INFO) make composer.check $(RESET)\t run phpunit and static analysis $(E)" 102 | @printf "\n" 103 | 104 | # 105 | # install command 106 | # 107 | init: do.copy 108 | @printf $(DOCKER_ICO) && printf "$(GOOD)running docker build and up $(E)" 109 | @mkdir -p app && touch app/.gitkeep 110 | @docker-compose build --build-arg UID=$(shell id -u) --build-arg ENV=dev --build-arg HOST_OS=$(shell uname -s) 111 | @$(DC_UP) 112 | init.nocache: do.copy 113 | @printf $(DOCKER_ICO) && printf "$(GOOD)running docker build --no-cache and up $(E)" 114 | @mkdir -p app && touch app/.gitkeep 115 | @docker-compose build --build-arg UID=$(shell id -u) --build-arg ENV=dev --no-cache --build-arg HOST_OS=$(shell uname -s) 116 | @$(DC_UP) 117 | 118 | # 119 | # docker & docker-compose commands 120 | # 121 | start: do.copy 122 | @printf $(DOCKER_ICO) && printf "$(GOOD)start $(S) $(CMD) $(DC_START) $(E)" 123 | @$(DC_START) 124 | stop: 125 | @printf $(DOCKER_ICO) && printf "$(WARN)stop $(S) $(CMD) $(DC_STOP) $(E)" 126 | @$(DC_STOP) 127 | up: do.copy 128 | @printf $(DOCKER_ICO) && printf "$(GOOD)up $(S) $(CMD) $(DC_UP) -d $(E)" 129 | @$(DC_UP) -d 130 | down: 131 | @printf $(DOCKER_ICO) && printf "$(WARN)down $(S) $(CMD) $(DC_DOWN) $(E)" 132 | @$(DC_DOWN) 133 | restart: stop 134 | @printf $(DOCKER_ICO) && printf "$(GOOD)start $(S) $(CMD) $(DC_START) $(E)" 135 | @$(DC_START) 136 | php.restart: 137 | @printf $(DOCKER_ICO) && printf "$(GOOD)restart $(S) php $(CMD) $(DC_STOP) php $(CMD) $(DC_START) php $(E)" 138 | @$(DC_STOP) php 139 | @cp .docker/php.env.development .docker/php.env 140 | @$(DC_START) php 141 | 142 | # 143 | # container shell commands 144 | # 145 | php.sh: 146 | @printf $(SHELL_ICO) && printf "$(INFO)php $(S) $(CMD) $(PHP_SH) $(E)" 147 | @$(PHP_SH) 148 | db.sh: 149 | @printf $(SHELL_ICO) && printf "$(INFO)db $(S) $(CMD) $(DB_SH) $(E)" 150 | @$(DB_SH) 151 | db.mysql: 152 | @printf $(MYSQL_ICO) && printf "$(INFO)mysql $(S) $(CMD) $(MYSQL_SH) $(E)" 153 | @$(MYSQL_SH) 154 | web.sh: 155 | @printf $(SHELL_ICO) && printf "$(INFO)web $(S) $(CMD) $(WEB_SH) $(E)" 156 | @$(WEB_SH) 157 | 158 | # 159 | # xdebug 160 | # 161 | xdebug.on: 162 | @printf $(XDEBUG_ICO) && printf "$(INFO)start xdebug $(S)" 163 | @docker container stop $(PHP) > /dev/null 164 | @sed -i '/xdebug.mode/c\xdebug.mode=coverage,debug' $(PHP_DEV_PATH)/conf.d/20-overrides.ini 165 | @docker container start $(PHP) > /dev/null 166 | @printf "$(GOOD) xdebug on $(E)" 167 | xdebug.off: 168 | @printf $(XDEBUG_ICO) && printf "$(INFO)stop xdebug $(S)" 169 | @docker container stop $(PHP) > /dev/null 170 | @sed -i '/xdebug.mode/c\xdebug.mode=off' $(PHP_DEV_PATH)/conf.d/20-overrides.ini 171 | @docker container start $(PHP) > /dev/null 172 | @printf "$(WARN) xdebug off $(E)" 173 | 174 | # 175 | # composer commands 176 | # 177 | composer.install: 178 | @printf $(COMP_ICO) && printf "$(INFO)installing $(S) $(CMD) $(COMP_INSTALL) $(E)" 179 | @$(COMP_INSTALL) 180 | @docker exec $(PHP) composer dump-autoload 181 | composer.test: 182 | @printf $(COMP_ICO) && printf "$(INFO)testing $(S) $(CMD) $(COMP_TEST) $(E)" 183 | @$(COMP_TEST) 184 | composer.check: 185 | @printf $(COMP_ICO) && printf "$(INFO)checking $(S) $(CMD) $(COMP_CHECK) $(E)" 186 | @$(COMP_CHECK) 187 | 188 | # 189 | # internal 190 | # 191 | do.copy: 192 | @cp $(PHP_DEV_PATH)/conf.d/20-overrides.ini.development $(PHP_DEV_PATH)/conf.d/20-overrides.ini 193 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🍰 CakePHP Docker 2 | 3 | [![Build](https://github.com/cnizzardini/cakephp-docker/workflows/Build/badge.svg?branch=master)](https://github.com/cnizzardini/cakephp-docker/actions) 4 | [![CakePHP](https://img.shields.io/badge/cakephp-5-red?logo=cakephp)](https://book.cakephp.org/5/en/index.html) 5 | [![Docker](https://img.shields.io/badge/docker-ffffff.svg?logo=docker)](.docker) 6 | [![Kubernetes](https://img.shields.io/badge/kubernetes-D3D3D3.svg?logo=kubernetes)](.kube) 7 | [![PHP](https://img.shields.io/badge/php-8.3-8892BF.svg?logo=php)](https://hub.docker.com/_/php) 8 | [![NGINX](https://img.shields.io/badge/nginx-1.19-009639.svg?logo=nginx)](https://hub.docker.com/_/nginx) 9 | [![MySQL](https://img.shields.io/badge/mysql-8-00758F.svg?logo=mysql)](https://hub.docker.com/_/mysql) 10 | 11 | A [cakephp/app](https://github.com/cakephp/app) template for Docker Compose and Kubernetes. You might also be 12 | interested in [CakePHP Galley](https://gitlab.com/amayer5125/galley) which is similar to Laravel Sail 13 | or [DevilBox](https://devilbox.readthedocs.io/en/latest/examples/setup-cakephp.html). 14 | 15 | #### Dependencies: 16 | 17 | - [Docker 20](https://docs.docker.com/engine/release-notes/) or higher 18 | - Make 19 | 20 | | Service | Host:Port | Docker Host | Image | 21 | |------------------------|----------------|-------------|----------------------------------------------------------------------------------------------| 22 | | PHP8.3-FPM w/ Xdebug 3 | - | php | [cnizzardini/php-fpm-alpine:8.3-latest](https://hub.docker.com/r/cnizzardini/php-fpm-alpine) | 23 | | NGINX 1.19 | localhost:8080 | web | [nginx:1.19-alpine](https://hub.docker.com/_/nginx) | 24 | | MySQL 8 | localhost:3607 | db | [library/mysql:8](https://hub.docker.com/_/mysql) | 25 | 26 | 27 | - [Installation](#installation) 28 | - [MacOS Notes](#mac-notes) 29 | - [Usage](#usage) 30 | - [PHP](#php) 31 | - [MySQL](#mysql) 32 | - [NGINX](#nginx) 33 | - [Xdebug](#xdebug) 34 | - [Reinstall](#reinstall) 35 | 36 | ## Installation 37 | 38 | Fork and clone this repository then run: 39 | 40 | ```console 41 | make init 42 | ``` 43 | 44 | That's it! Now just remove `app/*` from [.gitignore](.gitignore). You may also want to remove 45 | [.assets](.assets) and adjust defaults in [.github](.github), [.docker](.docker), and [.kube](.kube). 46 | 47 | > Note: `make init` and `make init.nocache` output interactively, while `make start` and `make up` do not. 48 | 49 | ## Mac Notes 50 | 51 | 1. Change your `SHELL` in the Makefile to `/bin/zsh`. This improves various output from the Makefile such as emoji's. 52 | 53 | 3. Mac ships with an older version of `sed` so install `gnu-sed` for some targets in the Makefile: 54 | 55 | ```console 56 | brew install gnu-sed 57 | ``` 58 | 59 | Then update `sed` to `gsed` in the Makefile. 60 | 61 | ## Usage 62 | 63 | After install browse to [http://localhost:8080](http://localhost:8080) to see the CakePHP welcome page. 64 | 65 | A [Makefile](Makefile) is provided with some optional commands for your convenience. Please review the Makefile as 66 | these commands are not exact aliases of docker-compose commands. 67 | 68 | | Make Command | Description | 69 | |-------------------------|-----------------------------------------------------------------------------------------| 70 | | `make` | Shows all make target commands | 71 | | `make init` | Runs docker build, docker-compose up, and copies over env files | 72 | | `make init.nocache` | Same as make.init but builds with --no-cache | 73 | | `make start` | Starts services `docker-compose -f .docker/docker-compose.yml start` | 74 | | `make stop` | Stops services `docker-compose -f .docker/docker-compose.yml stop` | 75 | | `make up` | Create and start containers `docker-compose -f .docker/docker-compose.yml up -d` | 76 | | `make down` | Take down and remove all containers `docker-compose -f .docker/docker-compose.yml down` | 77 | | `make restart` | Restarts services `docker-compose -f .docker/docker-compose.yml restart` | 78 | | `make php.sh` | PHP terminal `docker exec -it --user cakephp sh` | 79 | | `make php.restart` | Restarts the PHP container | 80 | | `make db.sh` | DB terminal `docker exec -it sh` | 81 | | `make db.mysql` | MySQL terminal `mysql -u root -h 0.0.0.0 -p --port 3307` | 82 | | `make web.sh` | Web terminal `docker exec -it sh` | 83 | | `make xdebug.on` | Restarts PHP container with xdebug.mode set to debug,coverage | 84 | | `make xdebug.off` | Restarts PHP container with xdebug.mode set to off | 85 | | `make composer.install` | `docker exec composer install --no-interaction` | 86 | | `make composer.test` | `docker exec composer test` | 87 | | `make composer.check` | `docker exec composer check` | 88 | 89 | ### PHP 90 | 91 | See [.docker/README.md](.docker/README.md) for details. 92 | 93 | Shell: 94 | 95 | ```console 96 | make php.sh 97 | ``` 98 | 99 | Helper commands: 100 | 101 | ```console 102 | make composer.install 103 | make composer.test 104 | make composer.check 105 | ``` 106 | 107 | ### MySQL 108 | 109 | See [.docker/README.md](.docker/README.md) for details. 110 | 111 | Shell: 112 | 113 | ```console 114 | make db.sh 115 | ``` 116 | 117 | MySQL shell (requires mysql client on your localhost): 118 | 119 | ```console 120 | make db.mysql 121 | ``` 122 | 123 | ### NGINX 124 | 125 | See [.docker/README.md](.docker/README.md) for details. 126 | 127 | Shell: 128 | 129 | ```console 130 | make web.sh 131 | ``` 132 | 133 | ### Xdebug 134 | 135 | Xdebug is disabled by default. To toggle: 136 | 137 | ```console 138 | make xdebug.on 139 | make xdebug.off 140 | ``` 141 | 142 | ### PHPStorm + Xdebug 143 | 144 | Xdebug 3's default port is `9003`. 145 | 146 | Go to `File > Settings > Languages & Frameworks > PHP > Servers` 147 | 148 | - Name: `localhost` 149 | - Host: `localhost` 150 | - Port: `8080` 151 | - Debugger: `Xdebug` 152 | - Use path mappings: `Enable` 153 | 154 | Map your project's app directory to the absolute path on the docker container `/srv/app` 155 | 156 | ## Reinstall 157 | 158 | To completely reinstall delete existing containers and images, then remove the `app/` directory and run `make init` 159 | again. 160 | -------------------------------------------------------------------------------- /app/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnizzardini/cakephp-docker/7cda7a096e92d6ca88a37d9671ad9b39a9276871/app/.gitkeep -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | php: 5 | build: 6 | context: . 7 | target: cakephp_php 8 | env_file: 9 | - ./.docker/php.env.development 10 | environment: 11 | PHP_IDE_CONFIG: "serverName=localhost" 12 | volumes: 13 | - ./app:/srv/app 14 | - ./.docker/php/development:/usr/local/etc/php 15 | - ~/.ssh/:/home/root/.ssh 16 | depends_on: 17 | - db 18 | 19 | db: 20 | image: library/mysql:8 21 | command: mysqld --sql_mode="" --default-authentication-plugin=mysql_native_password 22 | restart: always 23 | env_file: 24 | - ./.docker/mysql.env.development 25 | volumes: 26 | - data:/var/lib/mysql 27 | ports: 28 | - "3307:3306" 29 | 30 | web: 31 | image: nginx:1.19-alpine 32 | working_dir: /srv/app/ 33 | environment: 34 | TERM: Linux 35 | volumes: 36 | - ./app:/srv/app 37 | - ./.docker/nginx:/etc/nginx/conf.d 38 | ports: 39 | - "8080:80" 40 | depends_on: 41 | - php 42 | volumes: 43 | data: 44 | --------------------------------------------------------------------------------