1
0
mirror of https://github.com/halaxa/json-machine.git synced 2025-01-30 19:07:36 +01:00
json-machine/build/build-image.sh

37 lines
1017 B
Bash
Executable File

#!/usr/bin/env sh
set -e
PHP_MINOR=$1
PHP_VERSION=$( (wget -qO- "https://hub.docker.com/v2/repositories/library/php/tags?page_size=100&name=$PHP_MINOR" \
| grep -Po "[0-9]+\.[0-9]+\.[0-9]+(?=-)" \
|| echo "$PHP_MINOR") \
| head -1 \
)
XDEBUG_VERSION=$2
FROM_IMAGE="php:$PHP_VERSION-cli-alpine"
CONTAINER_NAME="json-machine-php-$PHP_VERSION"
docker ps --all --format "{{.Names}}" | grep "$CONTAINER_NAME" && docker rm -f "$CONTAINER_NAME"
>&2 echo "Building $CONTAINER_NAME from $FROM_IMAGE"
printf "
FROM $FROM_IMAGE
RUN apk add --update \
autoconf \
g++ \
libtool \
make \
&& wget http://pear.php.net/go-pear.phar && php go-pear.phar \
&& pecl install xdebug-$XDEBUG_VERSION \
&& docker-php-ext-enable xdebug \
&& wget https://getcomposer.org/download/latest-stable/composer.phar -O /usr/local/bin/composer \
&& chmod +x /usr/local/bin/composer
" | docker build --quiet --tag "$CONTAINER_NAME" - > /dev/null
echo "$CONTAINER_NAME"