Commit a7230fe1 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Build imagick extension from tagged source tarballs

This allows control of the version installed, and ensures greated
stability than pulling the git master.
parent 7480cd5c
Loading
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -14,7 +14,10 @@ RUN --mount=type=bind,source=scripts/install-deps.sh,target=/stage /stage
FROM deps as compile
RUN --mount=type=bind,source=scripts/install-build-deps.sh,target=/stage /stage
RUN --mount=type=bind,source=scripts/compile-dist-ext.sh,target=/stage /stage
RUN --mount=type=bind,source=scripts/compile-imagick.sh,target=/stage /stage

ARG imagick_version
RUN --mount=type=bind,source=scripts/compile-imagick.sh,target=/stage \
    /stage ${imagick_version}

FROM deps as fastcgi

+50 −1
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2019-2021 Dominik Sekotill <dom.sekotill@kodo.org.uk>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

set -eux
shopt -s lastpipe

VERSION=${1-}


int_version()
{
	local IFS=. major minor patch
	read major minor patch <<<"$1"
	printf "%d%d%d" $((major*10000)) $((minor*100)) $patch
}

get_latest()
{
	declare -n array=$1
	local IFS=$'\n'
	sort -nr <<<"${!array[*]}" |
	head -n1
}

get_tarball()
{
	local release url version
	declare -A URLS=() RELEASES=()

	curl -sS https://api.github.com/repos/imagick/imagick/tags |
	jq -r '.[] | [.name, .tarball_url] | @tsv' |
	while read release url; do
		[[ $release =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] &&
			RELEASES[$(int_version $release)]=$release
		URLS[$release]=$url
	done

	if [[ -n $VERSION ]]; then
		url=${URLS[$VERSION]}
	else
		release=${RELEASES[`get_latest RELEASES`]}
		url=${URLS[$release]}
	fi

	curl -sSL $url | gunzip -c
}


cd $(mktemp -d)

git clone --depth 1 https://github.com/imagick/imagick.git .
get_tarball | tar -xf- --strip-components=1
phpize
./configure
make install
+6 −1
Original line number Diff line number Diff line
#!/bin/sh
# Copyright 2019-2021 Dominik Sekotill <dom.sekotill@kodo.org.uk>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

set -eux

# Install packaged dependencies
@@ -6,7 +12,6 @@ apk update
apk add \
	autoconf \
	build-base \
	git \
	gmp-dev \
	imagemagick-dev \
	jpeg-dev \