├── .env ├── .env.local ├── .github └── workflows │ └── deploy.yaml ├── .gitignore ├── README.md ├── app ├── .gitignore ├── composer.json ├── phpunit.xml └── public │ └── index.php ├── bin └── dev-mode.sh ├── docker-compose.dev.yaml ├── docker-compose.yaml ├── nginx ├── Dockerfile └── conf.d │ └── default.conf ├── php ├── Dockerfile └── conf.d │ └── xdebug.ini └── sql └── docker-php.sql /.env: -------------------------------------------------------------------------------- 1 | MYSQL_PORT: 3306 2 | MYSQL_PASSWORD: secret 3 | MYSQL_DATABASE: docker-php 4 | MYSQL_USER: user 5 | REDIS_PORT: 6379 6 | -------------------------------------------------------------------------------- /.env.local: -------------------------------------------------------------------------------- 1 | MYSQL_PORT: 3306 2 | MYSQL_PASSWORD: secret 3 | MYSQL_DATABASE: docker-php 4 | MYSQL_USER: user 5 | REDIS_PORT: 6379 6 | BUILD_TARGET: app_dev 7 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yaml: -------------------------------------------------------------------------------- 1 | name: TranslateThis 2 | on: 3 | push: 4 | branches: 5 | - develop 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | # - name: Install Composer Dependencies 12 | # working-directory: ./app 13 | # run: composer install --prefer-dist 14 | # - name: Run Tests 15 | # working-directory: ./app 16 | # run: composer run-phpunit 17 | - run: docker build --target app -t garyclarke/php-composer:1.2 -f ./php/Dockerfile . 18 | - run: docker build -t garyclarke/nginx-php:1.0 -f ./nginx/Dockerfile . 19 | - run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} 20 | - run: docker push garyclarke/php-composer:1.2 21 | - run: docker push garyclarke/nginx-php:1.0 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/phpstorm 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=phpstorm 3 | 4 | ### PhpStorm ### 5 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 6 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 7 | 8 | # User-specific stuff 9 | .idea/**/workspace.xml 10 | .idea/**/tasks.xml 11 | .idea/**/usage.statistics.xml 12 | .idea/**/dictionaries 13 | .idea/**/shelf 14 | 15 | # AWS User-specific 16 | .idea/**/aws.xml 17 | 18 | # Generated files 19 | .idea/**/contentModel.xml 20 | 21 | # Sensitive or high-churn files 22 | .idea/**/dataSources/ 23 | .idea/**/dataSources.ids 24 | .idea/**/dataSources.local.xml 25 | .idea/**/sqlDataSources.xml 26 | .idea/**/dynamic.xml 27 | .idea/**/uiDesigner.xml 28 | .idea/**/dbnavigator.xml 29 | 30 | # Gradle 31 | .idea/**/gradle.xml 32 | .idea/**/libraries 33 | 34 | # Gradle and Maven with auto-import 35 | # When using Gradle or Maven with auto-import, you should exclude module files, 36 | # since they will be recreated, and may cause churn. Uncomment if using 37 | # auto-import. 38 | # .idea/artifacts 39 | # .idea/compiler.xml 40 | # .idea/jarRepositories.xml 41 | # .idea/modules.xml 42 | # .idea/*.iml 43 | # .idea/modules 44 | # *.iml 45 | # *.ipr 46 | 47 | # CMake 48 | cmake-build-*/ 49 | 50 | # Mongo Explorer plugin 51 | .idea/**/mongoSettings.xml 52 | 53 | # File-based project format 54 | *.iws 55 | 56 | # IntelliJ 57 | out/ 58 | 59 | # mpeltonen/sbt-idea plugin 60 | .idea_modules/ 61 | 62 | # JIRA plugin 63 | atlassian-ide-plugin.xml 64 | 65 | # Cursive Clojure plugin 66 | .idea/replstate.xml 67 | 68 | # SonarLint plugin 69 | .idea/sonarlint/ 70 | 71 | # Crashlytics plugin (for Android Studio and IntelliJ) 72 | com_crashlytics_export_strings.xml 73 | crashlytics.properties 74 | crashlytics-build.properties 75 | fabric.properties 76 | 77 | # Editor-based Rest Client 78 | .idea/httpRequests 79 | 80 | # Android studio 3.1+ serialized cache file 81 | .idea/caches/build_file_checksums.ser 82 | 83 | ### PhpStorm Patch ### 84 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 85 | 86 | # *.iml 87 | # modules.xml 88 | # .idea/misc.xml 89 | # *.ipr 90 | 91 | # Sonarlint plugin 92 | # https://plugins.jetbrains.com/plugin/7973-sonarlint 93 | .idea/**/sonarlint/ 94 | 95 | # SonarQube Plugin 96 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin 97 | .idea/**/sonarIssues.xml 98 | 99 | # Markdown Navigator plugin 100 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced 101 | .idea/**/markdown-navigator.xml 102 | .idea/**/markdown-navigator-enh.xml 103 | .idea/**/markdown-navigator/ 104 | 105 | # Cache file creation bug 106 | # See https://youtrack.jetbrains.com/issue/JBR-2257 107 | .idea/$CACHE_FILE$ 108 | 109 | # CodeStream plugin 110 | # https://plugins.jetbrains.com/plugin/12206-codestream 111 | .idea/codestream.xml 112 | 113 | # Azure Toolkit for IntelliJ plugin 114 | # https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij 115 | .idea/**/azureSettings.xml 116 | 117 | # End of https://www.toptal.com/developers/gitignore/api/phpstorm 118 | 119 | .idea 120 | 121 | branches.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker - PHP 2 | 3 | [Docker PHP][1] is a **Docker and PHP** repository which accompanies [a YouTube tutorial][2]. 4 | 5 | Setup 6 | ------------ 7 | 8 | * For a standard build / setup, simply run 9 | ```docker compose up -d ``` 10 | * For a development build which exposes DB ports and includes Xdebug, you can run the dev-mode shell script like so 11 | ```sh ./bin/dev-mode.sh -d``` 12 | * To run with Xdebug enabled, run 13 | ```XDEBUG_MODE=debug sh ./bin/dev-mode.sh -d --build``` 14 | 15 | 16 | Branches 17 | ------------- 18 | 19 | Each branch (except main, dev, and branches prefixed with 'feature') corresponds to an accompanying series lesson. 20 | 21 | Contributing 22 | ------------ 23 | 24 | Docker PHP is an Open Source project and contributions are welcome. The 'main' branch is read-only as this should not differ from the tutorials so please send pull requests to the develop branch. 25 | 26 | [1]: https://github.com/GaryClarke/docker-php 27 | [2]: https://youtu.be/qv-P_rPFw4c 28 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | composer.lock 2 | vendor 3 | .phpunit.result.cache -------------------------------------------------------------------------------- /app/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "garyclarke/translatethis", 3 | "description": "A Docker demo app for garyclarke.tech", 4 | "minimum-stability": "dev", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Gary Clarke", 9 | "email": "info@garyclarke.tech" 10 | } 11 | ], 12 | "require": { 13 | "php": "^8.0", 14 | "ext-pdo": "*", 15 | "ext-pdo_mysql": "*", 16 | "symfony/cache": "^6.1", 17 | "predis/predis": "^2.0" 18 | }, 19 | "require-dev": { 20 | "phpunit/phpunit": "^9.5" 21 | }, 22 | "autoload": { 23 | "psr-4": { 24 | "App\\": "src" 25 | } 26 | }, 27 | "scripts": { 28 | "run-phpunit": "vendor/bin/phpunit" 29 | } 30 | } -------------------------------------------------------------------------------- /app/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | tests 16 | 17 | 18 | 19 | 21 | 22 | src 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/public/index.php: -------------------------------------------------------------------------------- 1 |