Skip to content

Commit 882ef9b

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # build/hooks/_common
2 parents 02a8861 + bf9d4ba commit 882ef9b

File tree

5 files changed

+64
-20
lines changed

5 files changed

+64
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ This project adheres to [Semantic Versioning][semver].
88

99
Refer to master branch
1010

11-
## \[v1.1.1\] - 2019-10-13
11+
## \[v1.1.1\] - 2019-10-14
1212

13-
### Split PHP builds, PHP FPM:
13+
### Split PHP builds, PHP FPM, Latest tag:
1414
- Split builds by PHP version and variant
1515
- Use builds Docker hooks in Makefile
1616
- Added `fpm` variant
1717
- Now using `DOCKER_REPO` and `DOCKER_TAG` build variables
18+
- Push `latest` tags when building latest version (checks for Semantic Version in $SOURCE_BRANCH)
19+
- Set latest PHP version to 7.2 and variant to CLI
1820

1921
## \[v1.1.0\] - 2019-10-13
2022

Makefile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
# SOURCE_BRANCH
2-
SOURCE_BRANCH=1.1.1
31

4-
# DOCKER_REPO and DOCKER_TAG:
5-
# https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks
2+
# https://docs.docker.com/docker-hub/builds/advanced/#environment-variables-for-building-and-testing
3+
SOURCE_BRANCH:=$(shell git rev-parse --abbrev-ref HEAD)
64
DOCKER_REPO=jestefane/php-dev
75
DOCKER_TAG=
86

9-
# Possible versions: 5.5 5.6 7.0 7.1 7.2
7+
# Possible PHP versions: 5.5, 5.6, 7.0, 7.1, 7.2
108
PHP_VERSIONS=5.5 5.6 7.0 7.1 7.2
119

12-
# Possible VARIANT: cli, fpm, apache, alpine
10+
# Possible PHP variants: cli, fpm
1311
PHP_VARIANTS=cli fpm
1412

1513
BIN_DIR=/usr/local/bin

build/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# Possible versions: 5.5, 5.6, 7.0, 7.1, 7.2
1+
# PHP version and variant to build (defaults are latest)
22
ARG BUILD_PHP_VERSION=7.2
3-
# Possible VARIANT: cli, fpm, apache, alpine
43
ARG BUILD_PHP_VARIANT=cli
54

65
FROM php:$BUILD_PHP_VERSION-$BUILD_PHP_VARIANT

build/hooks/build

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
11
#!/usr/bin/env bash
22

3-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
3+
echo "************************************************"
4+
echo "* Start build hook *"
5+
echo "************************************************"
6+
echo
7+
8+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
49

510
# shellcheck source=./_common
611
. "$DIR/_common"
712

813
for php_version in $PHP_VERSIONS; do
914
xdebug_version=
1015
if [ "$php_version" == "5.5" ] || [ "$php_version" == "5.6" ]; then
11-
echo "Using XDebug version $xdebug_version"
16+
echo "Using XDebug version: ${xdebug_version:-latest}"
1217
xdebug_version=-2.5.5
13-
fi;
18+
fi
1419
for php_variant in $PHP_VARIANTS; do
15-
image_name="$DOCKER_REPO:$php_version-$php_variant-$SOURCE_BRANCH"
16-
echo "Building image: $image_name"
20+
if [ -z "$HAS_IMAGE_NAME" ] || [ -z "$IMAGE_NAME" ]; then
21+
IMAGE_NAME="$DOCKER_REPO:$php_version-$php_variant-$SOURCE_BRANCH"
22+
echo ">>> Set IMAGE_NAME to: $IMAGE_NAME"
23+
fi
24+
25+
echo "Building image: $IMAGE_NAME"
1726
docker build \
18-
-t "$image_name" \
27+
-t "$IMAGE_NAME" \
1928
--build-arg BUILD_PHP_VERSION="$php_version" \
2029
--build-arg BUILD_PHP_VARIANT="$php_variant" \
2130
--build-arg BUILD_XDEBUG_VERSION="$xdebug_version" "$DIR/.."
2231
done
2332
done
2433

34+
echo
35+
echo "************************************************"
36+
echo "* End build hook *"
37+
echo "************************************************"
38+
echo
39+
2540
exit 0

build/hooks/post_push

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,46 @@
11
#!/usr/bin/env bash
22

3-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
3+
echo "************************************************"
4+
echo "* Start post_push hook *"
5+
echo "************************************************"
6+
echo
7+
8+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
49

510
# shellcheck source=./_common
611
. "$DIR/_common"
712

13+
SEMVER_REGEX="^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
14+
815
for php_version in $PHP_VERSIONS; do
916
for php_variant in $PHP_VARIANTS; do
10-
image_name="$DOCKER_REPO:$php_version-$php_variant-$SOURCE_BRANCH"
11-
echo Pushing tag: "$image_name"
12-
docker push "$image_name"
17+
if [ -z "$HAS_IMAGE_NAME" ] || [ -z "$IMAGE_NAME" ]; then
18+
IMAGE_NAME="$DOCKER_REPO:$php_version-$php_variant-$SOURCE_BRANCH"
19+
echo ">>> Set IMAGE_NAME to: $IMAGE_NAME"
20+
fi
21+
22+
# Is this a release?
23+
if [[ $SOURCE_BRANCH =~ $SEMVER_REGEX ]]; then
24+
# Set the short tags
25+
short_tag="$DOCKER_REPO:$php_version-$php_variant"
26+
echo Pushing short tag: "$short_tag"
27+
docker tag "$IMAGE_NAME" "$short_tag"
28+
29+
# Is this the latest PHP version/variant?
30+
if [ "$php_version" == "7.2" ] && [ "$php_variant" == "cli" ]; then
31+
latest_tag="$DOCKER_REPO:latest"
32+
echo Pushing latest tag: "$latest_tag"
33+
docker tag "$IMAGE_NAME" "$latest_tag"
34+
fi
35+
docker push "$latest_tag"
36+
fi
1337
done
1438
done
1539

40+
echo
41+
echo "************************************************"
42+
echo "* End post_push hook *"
43+
echo "************************************************"
44+
echo
45+
1646
exit 0

0 commit comments

Comments
 (0)