├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── build.yml │ └── license.yml ├── .gitignore ├── .gitlab-ci.yml ├── Dockerfile ├── LICENSE └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: [ "https://boosty.to/dragon-code", "https://yoomoney.ru/to/410012608840929" ] 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - 4 | package-ecosystem: github-actions 5 | directory: / 6 | schedule: 7 | interval: daily 8 | timezone: UTC 9 | time: '00:00' 10 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Docker Build 2 | 3 | on: 4 | schedule: 5 | - cron: 17 4 * * * 6 | push: 7 | branches: 8 | - main 9 | tags: 10 | - v* 11 | workflow_dispatch: 12 | 13 | env: 14 | DOCKER_IMAGE: helldar/laravel-gitlab-ci 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-latest 19 | 20 | strategy: 21 | matrix: 22 | php_version: [ 8.2.28, 8.3.22, 8.4.8, latest ] 23 | 24 | steps: 25 | - name: Checkout 26 | uses: actions/checkout@v4 27 | 28 | - name: Set up Docker Buildx 29 | uses: docker/setup-buildx-action@v3 30 | 31 | - name: Login to DockerHub 32 | uses: docker/login-action@v3 33 | with: 34 | username: ${{ secrets.DOCKERHUB_USERNAME }} 35 | password: ${{ secrets.DOCKERHUB_TOKEN }} 36 | 37 | - name: Get the version 38 | id: get_version 39 | run: | 40 | VERSION=${{ matrix.php_version }} 41 | PREFIX="edge-" 42 | SUFFIX="-alpine" 43 | LATEST_TAG=edge 44 | LATEST_TAGS="${DOCKER_IMAGE}:edge,${DOCKER_IMAGE}:unstable" 45 | 46 | if [[ $VERSION == "latest" ]]; then 47 | SUFFIX="" 48 | fi 49 | 50 | echo "prefix=${PREFIX}" >> "$GITHUB_OUTPUT" 51 | echo "suffix=${SUFFIX}" >> "$GITHUB_OUTPUT" 52 | echo "minor_version=${VERSION:0:3}" >> "$GITHUB_OUTPUT" 53 | echo "full_version=${VERSION}" >> "$GITHUB_OUTPUT" 54 | echo "latest_tag=${LATEST_TAG}" >> "$GITHUB_OUTPUT" 55 | echo "latest_tags=${LATEST_TAGS}" >> "$GITHUB_OUTPUT" 56 | 57 | - name: Prepare 58 | id: prepare 59 | env: 60 | SHORT_PHP_VERSION: ${{ steps.get_version.outputs.minor_version }} 61 | FULL_PHP_VERSION: ${{ steps.get_version.outputs.full_version }} 62 | run: | 63 | echo "docker_image=${DOCKER_IMAGE}" >> "$GITHUB_OUTPUT" 64 | echo "minor_version=${SHORT_PHP_VERSION}" >> "$GITHUB_OUTPUT" 65 | echo "patch_version=${FULL_PHP_VERSION}" >> "$GITHUB_OUTPUT" 66 | 67 | - name: Build and Push (latest) 68 | if: success() && matrix.php_version == 'latest' 69 | uses: docker/build-push-action@v6 70 | with: 71 | context: . 72 | file: ./Dockerfile 73 | push: true 74 | tags: ${{ steps.get_version.outputs.latest_tags }} 75 | build-args: | 76 | VERSION=${{ steps.get_version.outputs.latest_tag }} 77 | SHORT_PHP_VERSION=alpine 78 | FULL_PHP_VERSION=alpine 79 | BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') 80 | VCS_REF=${GITHUB_SHA::8} 81 | 82 | - name: Build and Push (version) 83 | if: success() && matrix.php_version != 'latest' 84 | uses: docker/build-push-action@v6 85 | with: 86 | context: . 87 | file: ./Dockerfile 88 | push: true 89 | tags: | 90 | ${{ steps.prepare.outputs.docker_image }}:${{ steps.get_version.outputs.prefix }}${{ steps.prepare.outputs.minor_version }} 91 | ${{ steps.prepare.outputs.docker_image }}:${{ steps.get_version.outputs.prefix }}${{ steps.prepare.outputs.patch_version }} 92 | build-args: | 93 | VERSION=${{ steps.get_version.outputs.prefix }}${{ steps.prepare.outputs.patch_version }} 94 | SHORT_PHP_VERSION=${{ steps.prepare.outputs.minor_version }} 95 | FULL_PHP_VERSION=${{ steps.prepare.outputs.patch_version }}${{ steps.get_version.outputs.suffix }} 96 | BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') 97 | VCS_REF=${GITHUB_SHA::8} 98 | 99 | - name: Inspect (latest) 100 | if: success() && matrix.php_version == 'latest' 101 | run: docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.get_version.outputs.latest_tag }} 102 | 103 | - name: Inspect (version) 104 | if: success() && matrix.php_version != 'latest' 105 | run: | 106 | docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.get_version.outputs.prefix }}${{ steps.prepare.outputs.minor_version }} 107 | docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.get_version.outputs.prefix }}${{ steps.prepare.outputs.patch_version }} 108 | 109 | description: 110 | runs-on: ubuntu-latest 111 | 112 | steps: 113 | - name: Checkout 114 | uses: actions/checkout@v4 115 | 116 | - name: Update repo description 117 | uses: peter-evans/dockerhub-description@v4 118 | with: 119 | username: ${{ secrets.DOCKERHUB_USERNAME }} 120 | password: ${{ secrets.DOCKERHUB_PASSWORD }} 121 | repository: helldar/laravel-gitlab-ci 122 | -------------------------------------------------------------------------------- /.github/workflows/license.yml: -------------------------------------------------------------------------------- 1 | name: Update license 2 | 3 | on: 4 | schedule: 5 | - cron: '0 3 1 1 *' 6 | workflow_dispatch: 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: true 11 | 12 | permissions: 13 | contents: write 14 | pull-requests: write 15 | 16 | jobs: 17 | License: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v4 21 | with: 22 | fetch-depth: 0 23 | - uses: FantasticFiasco/action-update-license-year@v3 24 | id: license 25 | with: 26 | token: ${{ secrets.GITHUB_TOKEN }} 27 | commitTitle: 'The year in the LICENSE file has been updated' 28 | prTitle: 'The year in the LICENSE file has been updated' 29 | - name: Merge PR 30 | if: steps.license.outputs.pullRequestNumber != '' 31 | env: 32 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 33 | run: gh pr merge --merge --delete-branch ${{ steps.license.outputs.pullRequestNumber }} 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: helldar/laravel-gitlab-ci:stable 2 | 3 | services: 4 | - mysql:latest 5 | - redis:latest 6 | 7 | variables: 8 | APP_NAME: "${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}" 9 | MYSQL_DATABASE: database_name 10 | MYSQL_ROOT_PASSWORD: secret 11 | GITLAB_HOST: 123.123.123.123 12 | GITLAB_PORT: "22" 13 | PRODUCTION_HOST: 123.123.123.123 14 | 15 | 16 | .init_ssh: &init_ssh | 17 | mkdir -p ~/.ssh 18 | chmod 700 ~/.ssh 19 | printf "Host $GITLAB_HOST\n\tHostname $GITLAB_HOST\n\tPort $GITLAB_PORT\n\tUser git\n\tIdentityFile ~/.ssh/id_rsa\n\n" >> ~/.ssh/config 20 | chmod 644 ~/.ssh/config 21 | echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_rsa 22 | chmod 600 ~/.ssh/id_rsa 23 | ssh-keyscan $PRODUCTION_HOST >> ~/.ssh/known_hosts 24 | ssh-keyscan $GITLAB_HOST >> ~/.ssh/known_hosts 25 | chmod 644 ~/.ssh/known_hosts 26 | 27 | .change_file_permissions: &change_file_permissions | 28 | find . -type f -not -path "./vendor/*" -exec chmod 664 {} \; 29 | find . -type d -not -path "./vendor/*" -exec chmod 775 {} \; 30 | 31 | .php_version: &php_version | 32 | php -v 33 | 34 | .composer_install: &composer_install | 35 | composer install --prefer-dist --no-interaction --no-progress --no-scripts 36 | 37 | 38 | composer: 39 | stage: build 40 | only: 41 | - main 42 | - release 43 | script: 44 | - *init_ssh 45 | - *php_version 46 | - *composer_install 47 | - cp .env.testing .env 48 | - php artisan key:generate -vvv 49 | artifacts: 50 | expire_in: 1 week 51 | paths: 52 | - .env 53 | 54 | npm: 55 | stage: build 56 | only: 57 | - main 58 | - release 59 | cache: 60 | key: ${CI_PROJECT_NAME}-${CI_COMMIT_REF_SLUG}-yarn 61 | paths: 62 | - node_modules 63 | script: 64 | - npm ci 65 | - npm run build 66 | artifacts: 67 | expire_in: 1 week 68 | paths: 69 | - node_modules 70 | - public/mix-manifest.json 71 | 72 | phpunit: 73 | stage: test 74 | only: 75 | - main 76 | - release 77 | dependencies: 78 | - composer 79 | - npm 80 | script: 81 | - *composer_install 82 | - php artisan migrate:fresh --seed --force -vvv 83 | - phpunit --no-coverage -v 84 | 85 | production: 86 | stage: deploy 87 | only: 88 | - release 89 | script: 90 | - *init_ssh 91 | - *composer_install 92 | - *change_file_permissions 93 | - dep deploy 94 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FULL_PHP_VERSION=8.4-alpine 2 | 3 | FROM php:${FULL_PHP_VERSION} 4 | 5 | LABEL maintainer="Andrey Helldar" 6 | 7 | ARG FULL_PHP_VERSION=alpine 8 | ARG SHORT_PHP_VERSION=8.4 9 | 10 | ENV DEBIAN_FRONTEND noninteractive 11 | 12 | ########################################################################### 13 | # Update timezones 14 | ########################################################################### 15 | ENV TZ=UTC 16 | RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 17 | 18 | ########################################################################### 19 | # Install dev dependencies 20 | ########################################################################### 21 | RUN apk add --update linux-headers 22 | 23 | RUN apk update && \ 24 | apk add --no-cache --virtual .build-deps \ 25 | $PHPIZE_DEPS \ 26 | curl-dev \ 27 | imagemagick-dev \ 28 | libtool \ 29 | libxml2-dev \ 30 | postgresql-dev \ 31 | sqlite-dev \ 32 | oniguruma-dev 33 | 34 | ########################################################################### 35 | # Install production dependencies 36 | ########################################################################### 37 | RUN apk add --no-cache \ 38 | autoconf \ 39 | bash \ 40 | curl \ 41 | g++ \ 42 | gcc \ 43 | git \ 44 | imagemagick \ 45 | libc-dev \ 46 | libpng-dev \ 47 | libzip-dev \ 48 | make \ 49 | mysql-client \ 50 | nodejs \ 51 | openssh-client \ 52 | postgresql-libs \ 53 | rsync \ 54 | wget \ 55 | yaml-dev \ 56 | yarn \ 57 | zlib-dev 58 | 59 | ########################################################################### 60 | # Update PECL channel 61 | ########################################################################### 62 | RUN pecl channel-update pecl.php.net 63 | 64 | ########################################################################### 65 | # Install Imagick 66 | ########################################################################### 67 | 68 | RUN if [ $SHORT_PHP_VERSION != 8.4 && $SHORT_PHP_VERSION != "alpine" ]; then \ 69 | apk add git --update --no-cache && \ 70 | git clone https://github.com/Imagick/imagick.git --depth 1 /tmp/imagick && \ 71 | cd /tmp/imagick && \ 72 | git fetch origin master && \ 73 | git switch master && \ 74 | cd /tmp/imagick && \ 75 | phpize && \ 76 | ./configure && \ 77 | make && \ 78 | make install && \ 79 | apk del git && \ 80 | docker-php-ext-enable imagick \ 81 | ;fi 82 | 83 | ########################################################################### 84 | # Install PECL and PEAR extensions 85 | ########################################################################### 86 | RUN pecl install redis && \ 87 | docker-php-ext-enable redis 88 | 89 | RUN if [ $SHORT_PHP_VERSION != 8.4 && $SHORT_PHP_VERSION != "alpine" ]; then \ 90 | pecl install xdebug && \ 91 | docker-php-ext-enable xdebug \ 92 | ;fi 93 | 94 | ########################################################################### 95 | # Configure 96 | ########################################################################### 97 | RUN docker-php-ext-configure zip 98 | 99 | RUN docker-php-ext-install \ 100 | bcmath \ 101 | calendar \ 102 | curl \ 103 | dom \ 104 | exif \ 105 | ftp \ 106 | gd \ 107 | mbstring \ 108 | opcache \ 109 | pcntl \ 110 | pdo \ 111 | pdo_mysql \ 112 | pdo_pgsql \ 113 | pdo_sqlite \ 114 | soap \ 115 | xml \ 116 | zip 117 | 118 | ########################################################################### 119 | # Install Composer 120 | ########################################################################### 121 | ENV COMPOSER_HOME /composer 122 | ENV COMPOSER_ALLOW_SUPERUSER 1 123 | 124 | ENV PATH $HOME/.composer/vendor/bin:~/.composer/vendor/bin:./vendor/bin:/vendor/bin:/composer/vendor/bin:$HOME/.composer/vendor/bin:/var/www/vendor/bin:$HOME/.local/composer/vendor/bin:$COMPOSER_HOME/vendor/bin:$PATH 125 | 126 | RUN curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer 127 | 128 | ########################################################################### 129 | # Install Composer & Node Dependencies 130 | ########################################################################### 131 | RUN composer global require \ 132 | deployer/deployer \ 133 | dragon-code/codestyler \ 134 | laravel/pint 135 | 136 | RUN curl -fsSL https://bun.sh/install | bash 137 | 138 | ########################################################################### 139 | # Show Versions 140 | ########################################################################### 141 | RUN composer --version 142 | RUN dep --version 143 | RUN codestyle --version 144 | RUN pint --version 145 | 146 | RUN php -v 147 | RUN node -v 148 | 149 | ########################################################################### 150 | # Clean Up 151 | ########################################################################### 152 | RUN apk del -f .build-deps 153 | 154 | # Setup working directory 155 | WORKDIR /var/www 156 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023-2025 Andrey Helldar 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 | # 🐳 Deploying Docker container 2 | 3 | Laravel Gitlab CI 4 | 5 | [![Docker Badge](https://img.shields.io/docker/pulls/helldar/laravel-gitlab-ci)](https://hub.docker.com/r/helldar/laravel-gitlab-ci/) 6 | [![Docker Build](https://github.com/andrey-helldar/laravel-gitlab-ci/actions/workflows/build.yml/badge.svg)](https://github.com/andrey-helldar/laravel-gitlab-ci/actions/workflows/build.yml) 7 | 8 | > [!NOTE] 9 | > It is not recommended to use this container in production. Only for development and deployment. 10 | > 11 | > The configuration file for GitLab can be found [here](.gitlab-ci.yml). 12 | 13 | 14 | ## Supported tags and respective `Dockerfile` links 15 | 16 | > [!WARNING] 17 | > 18 | > The latest supported version of PHP is 8.4. 19 | > 20 | > We will support the current versions of PHP (8.2, 8.3, and 8.4) until PHP 8.4 [support ends](https://www.php.net/supported-versions.php) on January 1, 2027. 21 | > 22 | > Also, the Imagick extension is not available for PHP 8.4 due to [lack of support](https://github.com/Imagick/imagick). 23 | 24 | | Tags | Stability | 25 | |:---------------------------------------------|:-------------------------------------------------------------------------------------| 26 | | `latest`, `stable`, `8.4`, `8.4.x` | latest stable | 27 | | `edge`, `unstable`, `edge-8.4`, `edge-8.4.x` | latest unstable | 28 | | `8.4`, `8.3`, `8.2` | stable minor | 29 | | `8.4.x`, `8.3.x`, `8.2.x` | stable patch, where `x` is the [PHP version number](https://www.php.net/downloads) | 30 | | `edge-8.4`, `edge-8.3`, `edge-8.2` | unstable | 31 | | `edge-8.4.x`, `edge-8.3.x`, `edge-8.2.x` | unstable patch, where `x` is the [PHP version number](https://www.php.net/downloads) | 32 | 33 | ## Unsupported but available 34 | 35 | | Tags | Stability | 36 | |:-----------------------------------------|:-------------------------------------------------------------------------------------| 37 | | `8.1`, `8.0`, `7.4` | stable minor | 38 | | `8.1.x`, `8.0.x`, `7.4.x` | stable patch, where `x` is the [PHP version number](https://www.php.net/downloads) | 39 | | `edge-8.1`, `edge-8.0`, `edge-7.4` | unstable | 40 | | `edge-8.0.x`, `edge-8.0.x`, `edge-7.4.x` | unstable patch, where `x` is the [PHP version number](https://www.php.net/downloads) | 41 | --------------------------------------------------------------------------------