From 4a20910ce47b00391d278a774701c36d32dea847 Mon Sep 17 00:00:00 2001 From: Alex Renoki Date: Mon, 12 Apr 2021 19:05:05 +0300 Subject: [PATCH] Added worker --- .github/workflows/docker-commit.yml | 31 ++++++++++++ .github/workflows/docker-latest-tag.yaml | 32 ++++++++++++ .github/workflows/docker-release-tag.yaml | 60 ++++++++++++++++++++++- Dockerfile.worker | 55 +++++++++++++++++++++ README.md | 5 ++ 5 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.worker diff --git a/.github/workflows/docker-commit.yml b/.github/workflows/docker-commit.yml index 80d7f45..5a36b4c 100644 --- a/.github/workflows/docker-commit.yml +++ b/.github/workflows/docker-commit.yml @@ -70,3 +70,34 @@ jobs: context: . tags: renokico/laravel-helm-demo:octane-${{ github.sha }} file: Dockerfile.octane + + worker_push: + if: "!contains(github.event.head_commit.message, 'skip ci')" + + runs-on: ubuntu-latest + + name: Tag Commit (Worker) + + steps: + - uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + id: docker + uses: docker/build-push-action@v2 + with: + push: true + context: . + tags: renokico/laravel-helm-demo:worker-${{ github.sha }} + file: Dockerfile.worker diff --git a/.github/workflows/docker-latest-tag.yaml b/.github/workflows/docker-latest-tag.yaml index 362463f..cdfd022 100644 --- a/.github/workflows/docker-latest-tag.yaml +++ b/.github/workflows/docker-latest-tag.yaml @@ -69,3 +69,35 @@ jobs: tags: renokico/laravel-helm-demo:octane-latest labels: ${{ steps.docker_meta.outputs.labels }} file: Dockerfile.octane + + push_worker: + if: "!contains(github.event.head_commit.message, 'skip ci')" + + runs-on: ubuntu-latest + + name: Tag Latest (Worker) + + steps: + - uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + id: docker + uses: docker/build-push-action@v2 + with: + push: true + context: . + tags: renokico/laravel-helm-demo:worker-latest + labels: ${{ steps.docker_meta.outputs.labels }} + file: Dockerfile.worker diff --git a/.github/workflows/docker-release-tag.yaml b/.github/workflows/docker-release-tag.yaml index 76862ab..a13869e 100644 --- a/.github/workflows/docker-release-tag.yaml +++ b/.github/workflows/docker-release-tag.yaml @@ -120,4 +120,62 @@ jobs: context: . tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} - file: Dockerfile.fpm + file: Dockerfile.octane + + push_worker: + if: "!contains(github.event.head_commit.message, 'skip ci')" + + runs-on: ubuntu-latest + + name: Tag Release (Worker) + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + extensions: dom, curl, intl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite + coverage: pcov + + - uses: actions/cache@v2.1.4 + name: Cache Composer dependencies + with: + path: ~/.composer/cache/files + key: composer-${{ hashFiles('composer.json') }} + + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v2.3.0 + with: + images: renokico/laravel-helm-demo + tags: | + type=semver,pattern=worker-{{version}} + type=semver,pattern=worker-{{major}}.{{minor}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Install dependencies + run: | + composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader --no-dev + + - name: Build and Push + id: docker + uses: docker/build-push-action@v2 + with: + push: true + context: . + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} + file: Dockerfile.worker diff --git a/Dockerfile.worker b/Dockerfile.worker new file mode 100644 index 0000000..ae14db5 --- /dev/null +++ b/Dockerfile.worker @@ -0,0 +1,55 @@ +FROM php:8.0-cli-alpine + +RUN apk --update add \ + wget \ + curl \ + build-base \ + composer \ + nodejs-current \ + nodejs-current-npm \ + libmcrypt-dev \ + libxml2-dev \ + pcre-dev \ + zlib-dev \ + autoconf \ + oniguruma-dev \ + openssl \ + openssl-dev \ + freetype-dev \ + libjpeg-turbo-dev \ + jpeg-dev \ + libpng-dev \ + imagemagick-dev \ + imagemagick \ + postgresql-dev \ + libzip-dev \ + gettext-dev \ + libxslt-dev \ + libgcrypt-dev && \ + pecl channel-update pecl.php.net && \ + pecl install mcrypt redis-5.3.4 && \ + docker-php-ext-install \ + mysqli \ + mbstring \ + pdo \ + pdo_mysql \ + tokenizer \ + xml \ + pcntl \ + bcmath \ + pdo_pgsql \ + zip \ + intl \ + gettext \ + soap \ + sockets \ + xsl && \ + docker-php-ext-configure gd --with-freetype=/usr/lib/ --with-jpeg=/usr/lib/ && \ + docker-php-ext-install gd && \ + docker-php-ext-enable redis && \ + rm -rf /tmp/pear && \ + rm /var/cache/apk/* + +COPY . /var/www + +ENTRYPOINT ["php", "-v"] diff --git a/README.md b/README.md index 5d17312..a8a72a9 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ - [Change deployment steps](#change-deployment-steps) - [Change PHP-FPM version](#change-php-fpm-version) - [Change Octane version](#change-octane-version) + - [Workers](#workers) - [Deploying](#deploying) - [Helm v3](#helm-v3) - [Autoscaling](#autoscaling) @@ -41,6 +42,10 @@ the final image will contain the project with dependencies installed, as long as The project contains an Octane-based image. Same as with the PHP-FPM version, you can change the Octane-based image by editing `Dockerfile.octane`. +### Workers + +The project contains an PHP CLI-based image that you can use to run your Laravel workers, such as queues or schedulers. To change the image, edit `Dockerfile.worker`. + ## Deploying ### Helm v3