Skip to content

Commit

Permalink
Merge pull request #1847 from tomudding/fix/imagick-not-building
Browse files Browse the repository at this point in the history
Fix Imagick not building and breaking image builds
  • Loading branch information
tomudding authored Jun 23, 2024
2 parents 72c7136 + a55221c commit 3f26bcc
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 52 deletions.
49 changes: 7 additions & 42 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ concurrency:
cancel-in-progress: true

env:
IMAGE_NAME_GLIDE: ${{ vars.ABC_DOCKER_REGISTRY }}/web/gewisweb/glide
IMAGE_NAME_MATOMO: ${{ vars.ABC_DOCKER_REGISTRY }}/web/gewisweb/matomo
IMAGE_NAME_NGINX: ${{ vars.ABC_DOCKER_REGISTRY }}/web/gewisweb/nginx
IMAGE_NAME_WEB: ${{ vars.ABC_DOCKER_REGISTRY }}/web/gewisweb/web
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
image: ['web', 'glide', 'matomo', 'nginx']
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -38,47 +36,14 @@ jobs:
username: ${{ secrets.SVC_GH_ABCWEB_USERNAME }}
password: ${{ secrets.SVC_GH_ABCWEB_PWD }}

- name: Build and push web image
- name: Build and push image
uses: docker/build-push-action@v6
with:
build-args: GIT_COMMIT=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: ${{ env.IS_RELEASE && './docker/web/production/Dockerfile' || './docker/web/development/Dockerfile' }}
platforms: linux/amd64
push: true
tags: ${{ format('{0}:{1}', env.IMAGE_NAME_WEB, env.IS_RELEASE && format('{0},{1}:latest', github.ref_name, env.IMAGE_NAME_WEB) || 'development') }}

- name: Build and push glide image
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: ./docker/glide
file: ./docker/glide/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ format('{0}:{1}', env.IMAGE_NAME_GLIDE, env.IS_RELEASE && format('{0},{1}:latest', github.ref_name, env.IMAGE_NAME_GLIDE) || 'development') }}

- name: Build and push matomo image
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: ./docker/matomo
file: ./docker/matomo/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ format('{0}:{1}', env.IMAGE_NAME_MATOMO, env.IS_RELEASE && format('{0},{1}:latest', github.ref_name, env.IMAGE_NAME_MATOMO) || 'development') }}

- name: Build and push nginx image
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: ./docker/nginx
file: ./docker/nginx/Dockerfile
context: ${{ matrix.image == 'web' && '.' || format('./docker/{0}', matrix.image) }}
file: ${{ matrix.image == 'web' && (env.IS_RELEASE && './docker/web/production/Dockerfile' || './docker/web/development/Dockerfile') || format('./docker/{0}/Dockerfile', matrix.image) }}
platforms: linux/amd64
push: true
tags: ${{ format('{0}:{1}', env.IMAGE_NAME_NGINX, env.IS_RELEASE && format('{0},{1}:latest', github.ref_name, env.IMAGE_NAME_NGINX) || 'development') }}
tags: ${{ format('{0}:{1}', format('{0}/web/gewisweb/{1}', vars.ABC_DOCKER_REGISTRY, matrix.image), env.IS_RELEASE && format('{0},{1}:latest', github.ref_name, format('{0}/web/gewisweb/{1}', vars.ABC_DOCKER_REGISTRY, matrix.image)) || 'development') }}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-intl": "*",
"ext-imagick": "^3.5.0",
"ext-imagick": "*",
"ext-mbstring": "*",
"ext-memcached": "^3.0.0",
"ext-openssl": "*",
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions docker/glide/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ RUN apk add --no-cache --virtual .build-deps \
gd \
opcache \
zip \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& rm -r /tmp/pear \
# START OF IMAGICK PATCH
# && pecl install imagick \
# Install Imagick from source as building it for PHP 8.3 keeps intermittently failing. This has been extensively
# documented at https://github.com/Imagick/imagick/issues/640. We do not need to patch anything, we will just use
# the current HEAD of the master branch (this is still 28f27044e435a2b203e32675e942eb8de620ee58).
&& mkdir -p /usr/src/php/ext/imagick \
&& curl -fsSL https://github.com/Imagick/imagick/archive/28f27044e435a2b203e32675e942eb8de620ee58.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1 \
&& docker-php-ext-install imagick \
# && docker-php-ext-enable imagick \
# && rm -r /tmp/pear \
# END OF IMAGICK PATCH
&& runtimeDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
Expand Down
12 changes: 10 additions & 2 deletions docker/web/development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,16 @@ RUN apk add --no-cache --virtual .build-deps \
pdo_pgsql \
pdo_sqlite \
zip \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
# START OF IMAGICK PATCH
# && pecl install imagick \
# Install Imagick from source as building it for PHP 8.3 keeps intermittently failing. This has been extensively
# documented at https://github.com/Imagick/imagick/issues/640. We do not need to patch anything, we will just use
# the current HEAD of the master branch (this is still 28f27044e435a2b203e32675e942eb8de620ee58).
&& mkdir -p /usr/src/php/ext/imagick \
&& curl -fsSL https://github.com/Imagick/imagick/archive/28f27044e435a2b203e32675e942eb8de620ee58.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1 \
&& docker-php-ext-install imagick \
# && docker-php-ext-enable imagick \
# END OF IMAGICK PATCH
&& pecl install memcached \
&& docker-php-ext-enable memcached \
&& pecl install xdebug \
Expand Down
12 changes: 10 additions & 2 deletions docker/web/production/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,16 @@ RUN apk add --no-cache --virtual .build-deps \
pdo_mysql \
pdo_pgsql \
zip \
&& pecl install -o imagick \
&& docker-php-ext-enable imagick \
# START OF IMAGICK PATCH
# && pecl install imagick \
# Install Imagick from source as building it for PHP 8.3 keeps intermittently failing. This has been extensively
# documented at https://github.com/Imagick/imagick/issues/640. We do not need to patch anything, we will just use
# the current HEAD of the master branch (this is still 28f27044e435a2b203e32675e942eb8de620ee58).
&& mkdir -p /usr/src/php/ext/imagick \
&& curl -fsSL https://github.com/Imagick/imagick/archive/28f27044e435a2b203e32675e942eb8de620ee58.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1 \
&& docker-php-ext-install imagick \
# && docker-php-ext-enable imagick \
# END OF IMAGICK PATCH
&& pecl install -o memcached \
&& docker-php-ext-enable memcached \
&& rm -r /tmp/pear \
Expand Down

0 comments on commit 3f26bcc

Please sign in to comment.