├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ └── packages.yml ├── 8.2 └── Dockerfile ├── 8.3 └── Dockerfile ├── 8.4 └── Dockerfile ├── LICENSE ├── README.md └── gitlab ├── .gitlab-ci.deployments.yml └── .gitlab-ci.tests.yml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [lorisleiva] 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "docker" 4 | directory: "/8.2" 5 | schedule: 6 | interval: "daily" 7 | ignore: 8 | - dependency-name: "*" 9 | update-types: ["version-update:semver-major"] 10 | 11 | - package-ecosystem: "docker" 12 | directory: "/8.3" 13 | schedule: 14 | interval: "daily" 15 | ignore: 16 | - dependency-name: "*" 17 | update-types: ["version-update:semver-major"] 18 | 19 | - package-ecosystem: "docker" 20 | directory: "/8.4" 21 | schedule: 22 | interval: "daily" 23 | ignore: 24 | - dependency-name: "*" 25 | update-types: ["version-update:semver-major"] 26 | 27 | - package-ecosystem: "github-actions" 28 | directory: "/" 29 | schedule: 30 | interval: "daily" 31 | -------------------------------------------------------------------------------- /.github/workflows/packages.yml: -------------------------------------------------------------------------------- 1 | name: Build and publish packages 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | env: 9 | IMAGE: lorisleiva/laravel-docker 10 | 11 | jobs: 12 | docker: 13 | runs-on: ubuntu-latest 14 | 15 | strategy: 16 | matrix: 17 | include: 18 | - tag: "latest" 19 | php: "8.4" 20 | - tag: "stable" 21 | php: "8.3" 22 | - tag: "8.4" 23 | php: "8.4" 24 | - tag: "8.3" 25 | php: "8.3" 26 | - tag: "8.2" 27 | php: "8.2" 28 | 29 | steps: 30 | - uses: actions/checkout@v3 31 | 32 | - name: Login to GitHub Container Registry 33 | uses: docker/login-action@v2 34 | with: 35 | registry: ghcr.io 36 | username: ${{ github.actor }} 37 | password: ${{ secrets.GITHUB_TOKEN }} 38 | 39 | - name: Login to DockerHub 40 | uses: docker/login-action@v2 41 | with: 42 | username: ${{ secrets.DOCKERHUB_USERNAME }} 43 | password: ${{ secrets.DOCKERHUB_TOKEN }} 44 | 45 | - name: Setup QEMU for multi-platform builds 46 | uses: docker/setup-qemu-action@v2 47 | with: 48 | platforms: linux/amd64,linux/arm64 49 | 50 | - name: Setup Docker Buildx 51 | uses: docker/setup-buildx-action@v2 52 | 53 | - name: Build and push 54 | id: docker_build 55 | uses: docker/build-push-action@v3 56 | with: 57 | push: true 58 | context: ${{ matrix.php }} 59 | platforms: linux/amd64,linux/arm64 60 | tags: | 61 | ghcr.io/${{ env.IMAGE }}:${{ matrix.tag }} 62 | ${{ env.IMAGE }}:${{ matrix.tag }} 63 | cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE }}:${{ matrix.tag }} 64 | cache-to: type=inline 65 | -------------------------------------------------------------------------------- /8.2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.2-alpine3.17 2 | 3 | # Add docker-php-extension-installer script 4 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ 5 | 6 | # Install dependencies 7 | RUN apk add --no-cache \ 8 | bash \ 9 | curl \ 10 | freetype-dev \ 11 | g++ \ 12 | gcc \ 13 | gcompat \ 14 | git \ 15 | icu-dev \ 16 | icu-libs \ 17 | libc-dev \ 18 | libzip-dev \ 19 | make \ 20 | mysql-client \ 21 | nodejs \ 22 | npm \ 23 | oniguruma-dev \ 24 | yarn \ 25 | openssh-client \ 26 | postgresql-libs \ 27 | rsync \ 28 | zlib-dev 29 | 30 | # Install php extensions 31 | RUN chmod +x /usr/local/bin/install-php-extensions && \ 32 | install-php-extensions \ 33 | @composer \ 34 | redis-stable \ 35 | imagick \ 36 | xdebug \ 37 | bcmath \ 38 | calendar \ 39 | exif \ 40 | gd \ 41 | intl \ 42 | pdo_mysql \ 43 | pdo_pgsql \ 44 | pcntl \ 45 | soap \ 46 | zip 47 | 48 | # Add local and global vendor bin to PATH. 49 | ENV PATH ./vendor/bin:/composer/vendor/bin:/root/.composer/vendor/bin:/usr/local/bin:$PATH 50 | 51 | # Install PHP_CodeSniffer 52 | RUN composer global require "squizlabs/php_codesniffer=*" 53 | 54 | # Setup working directory 55 | WORKDIR /var/www 56 | -------------------------------------------------------------------------------- /8.3/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.3-alpine3.17 2 | 3 | # Add docker-php-extension-installer script 4 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ 5 | 6 | # Install dependencies 7 | RUN apk add --no-cache \ 8 | bash \ 9 | curl \ 10 | freetype-dev \ 11 | g++ \ 12 | gcc \ 13 | gcompat \ 14 | git \ 15 | icu-dev \ 16 | icu-libs \ 17 | libc-dev \ 18 | libzip-dev \ 19 | make \ 20 | mysql-client \ 21 | nodejs \ 22 | npm \ 23 | oniguruma-dev \ 24 | yarn \ 25 | openssh-client \ 26 | postgresql-libs \ 27 | rsync \ 28 | zlib-dev 29 | 30 | # Install php extensions 31 | RUN chmod +x /usr/local/bin/install-php-extensions && \ 32 | install-php-extensions \ 33 | @composer \ 34 | redis-stable \ 35 | imagick \ 36 | xdebug \ 37 | bcmath \ 38 | calendar \ 39 | exif \ 40 | gd \ 41 | intl \ 42 | pdo_mysql \ 43 | pdo_pgsql \ 44 | pcntl \ 45 | soap \ 46 | zip 47 | 48 | # Add local and global vendor bin to PATH. 49 | ENV PATH ./vendor/bin:/composer/vendor/bin:/root/.composer/vendor/bin:/usr/local/bin:$PATH 50 | 51 | # Install PHP_CodeSniffer 52 | RUN composer global require "squizlabs/php_codesniffer=*" 53 | 54 | # Setup working directory 55 | WORKDIR /var/www 56 | -------------------------------------------------------------------------------- /8.4/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.4-alpine3.21 2 | 3 | # Add docker-php-extension-installer script 4 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ 5 | 6 | # Install dependencies 7 | RUN apk add --no-cache \ 8 | bash \ 9 | curl \ 10 | freetype-dev \ 11 | g++ \ 12 | gcc \ 13 | gcompat \ 14 | git \ 15 | icu-dev \ 16 | icu-libs \ 17 | libc-dev \ 18 | libzip-dev \ 19 | make \ 20 | mysql-client \ 21 | nodejs \ 22 | npm \ 23 | oniguruma-dev \ 24 | yarn \ 25 | openssh-client \ 26 | postgresql-libs \ 27 | rsync \ 28 | zlib-dev 29 | 30 | # Install php extensions 31 | RUN chmod +x /usr/local/bin/install-php-extensions && \ 32 | install-php-extensions \ 33 | @composer \ 34 | redis-stable \ 35 | imagick \ 36 | xdebug \ 37 | bcmath \ 38 | calendar \ 39 | exif \ 40 | gd \ 41 | intl \ 42 | pdo_mysql \ 43 | pdo_pgsql \ 44 | pcntl \ 45 | soap \ 46 | zip 47 | 48 | # Add local and global vendor bin to PATH. 49 | ENV PATH ./vendor/bin:/composer/vendor/bin:/root/.composer/vendor/bin:/usr/local/bin:$PATH 50 | 51 | # Install PHP_CodeSniffer 52 | RUN composer global require "squizlabs/php_codesniffer=*" 53 | 54 | # Setup working directory 55 | WORKDIR /var/www 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Loris Leiva 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # laravel-docker 2 | 3 | 🐳 Generic docker image for Laravel Applications 4 | 5 | [![Docker Badge](https://img.shields.io/docker/pulls/lorisleiva/laravel-docker)](https://hub.docker.com/r/lorisleiva/laravel-docker/) 6 | 7 | | Tags | PHP version | Architecture | Features | 8 | |--------|-------------|-------------|-----------------------------------------------------------------------------------------------------------------| 9 | | 8.2 | 8.2 | amd64/arm64 | ✅ Everything. | 10 | | 8.3 | 8.3 | amd64/arm64 | ✅ Everything. | 11 | | 8.4 | 8.4 | amd64/arm64 | ✅ Everything. | 12 | | stable | **8.3** | amd64/arm64 | 🔗 Aliases the latest stable version of PHP that supports all features of this docker image. | 13 | | latest | **8.4** | amd64/arm64 | 🔗 Aliases the latest stable version of PHP available (even if that version does not support all features yet). | 14 | 15 | #### Use within your GitLab's pipelines. 16 | 17 | - [Run test suite and check codestyle](http://lorisleiva.com/using-gitlabs-pipeline-with-laravel/) 18 | - [Build, test and deploy your Laravel application](http://lorisleiva.com/laravel-deployment-using-gitlab-pipelines/) 19 | -------------------------------------------------------------------------------- /gitlab/.gitlab-ci.deployments.yml: -------------------------------------------------------------------------------- 1 | image: lorisleiva/laravel-docker:latest 2 | 3 | .init_ssh: &init_ssh | 4 | eval $(ssh-agent -s) 5 | echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null 6 | mkdir -p ~/.ssh 7 | chmod 700 ~/.ssh 8 | [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config 9 | 10 | # Replace the last line with the following lines if you'd rather 11 | # leave StrictHostKeyChecking enabled (replace yourdomain.com): 12 | # 13 | # ssh-keyscan yourdomain.com >> ~/.ssh/known_hosts 14 | # chmod 644 ~/.ssh/known_hosts 15 | 16 | .change_file_permissions: &change_file_permissions | 17 | find . -type f -not -path "./vendor/*" -exec chmod 664 {} \; 18 | find . -type d -not -path "./vendor/*" -exec chmod 775 {} \; 19 | 20 | composer: 21 | stage: build 22 | cache: 23 | key: ${CI_COMMIT_REF_SLUG}-composer 24 | paths: 25 | - vendor/ 26 | script: 27 | - composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts 28 | - cp .env.example .env 29 | - php artisan key:generate 30 | artifacts: 31 | expire_in: 1 month 32 | paths: 33 | - vendor/ 34 | - .env 35 | 36 | npm: 37 | stage: build 38 | cache: 39 | key: ${CI_COMMIT_REF_SLUG}-npm 40 | paths: 41 | - node_modules/ 42 | script: 43 | - npm install 44 | - npm run production 45 | artifacts: 46 | expire_in: 1 month 47 | paths: 48 | - node_modules/ 49 | - public/css/ 50 | - public/js/ 51 | 52 | codestyle: 53 | stage: test 54 | dependencies: [] 55 | script: 56 | - phpcs --standard=PSR2 --extensions=php --ignore=app/Support/helpers.php app 57 | 58 | phpunit: 59 | stage: test 60 | dependencies: 61 | - composer 62 | script: 63 | - phpunit --coverage-text --colors=never 64 | 65 | staging: 66 | stage: deploy 67 | script: 68 | - *init_ssh 69 | - *change_file_permissions 70 | - php artisan deploy dev.yourdomain.com -s upload 71 | environment: 72 | name: staging 73 | url: http://dev.yourdomain.com 74 | only: 75 | - master 76 | 77 | production: 78 | stage: deploy 79 | script: 80 | - *init_ssh 81 | - *change_file_permissions 82 | - php artisan deploy yourdomain.com -s upload 83 | environment: 84 | name: production 85 | url: http://yourdomain.com 86 | when: manual 87 | only: 88 | - master 89 | -------------------------------------------------------------------------------- /gitlab/.gitlab-ci.tests.yml: -------------------------------------------------------------------------------- 1 | image: lorisleiva/laravel-docker:latest 2 | 3 | cache: 4 | key: ${CI_COMMIT_REF_SLUG} 5 | paths: 6 | - vendor/ 7 | 8 | codestyle: 9 | stage: test 10 | cache: {} 11 | script: 12 | - phpcs --standard=PSR2 --extensions=php app 13 | 14 | phpunit: 15 | stage: test 16 | script: 17 | - composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts 18 | - cp .env.example .env 19 | - php artisan key:generate 20 | - phpunit --coverage-text --colors=never 21 | --------------------------------------------------------------------------------