|
3 | 3 |
|
4 | 4 | # grab latest tags |
5 | 5 | PHP_TAGS=$(curl 'https://registry.hub.docker.com/v2/repositories/library/php/tags?page_size=1024' | grep -Po "[0-9]+\.[0-9]+\.[0-9]+-apache" | sed 's/-apache//' | sort | uniq) |
| 6 | +IS_MASTER_BUILD=$([ "$SOURCE_BRANCH" == "master" ] && echo 1 || echo 0) |
6 | 7 |
|
7 | | -if [ $DOCKER_TAG == "latest" ]; then |
| 8 | +echo "##### Build default image - ${IMAGE_NAME} #####" |
| 9 | +docker build --build-arg PHP_VERSION_TAG=${PHP_VERSION_TAG} -f $DOCKERFILE_PATH -t ${IMAGE_NAME} . |
8 | 10 |
|
9 | | - docker build --build-arg PHP_VERSION_TAG=${PHP_VERSION_TAG} -f $DOCKERFILE_PATH -t ${IMAGE_NAME} . |
10 | | - |
11 | | - for PHP_MAJOR in $(echo "$PHP_TAGS" | grep -Po "^[0-9]+" | sort | uniq); do |
12 | | - echo "##### Build ${PHP_MAJOR}-latest (x-latest) #####" |
13 | | - docker build --build-arg PHP_VERSION_TAG=${PHP_MAJOR}-apache -f ${DOCKERFILE_PATH} -t ${DOCKER_REPO}:${PHP_MAJOR}-latest . |
14 | | - done |
| 11 | +if [ $IS_MASTER_BUILD -eq 1 ]; then |
15 | 12 |
|
16 | 13 | for PHP_MINOR in $(echo "$PHP_TAGS" | grep -Po "^[0-9]+\.[0-9]+" | sort | uniq); do |
17 | | - echo "##### Build ${PHP_MINOR}-latest (x.y-latest) #####" |
18 | | - docker build --build-arg PHP_VERSION_TAG=${PHP_MINOR}-apache -f ${DOCKERFILE_PATH} -t ${DOCKER_REPO}:${PHP_MINOR}-latest . |
| 14 | + echo "##### Build ${PHP_MINOR} #####" |
| 15 | + docker build --build-arg PHP_VERSION_TAG=${PHP_MINOR}-apache -f ${DOCKERFILE_PATH} -t ${DOCKER_REPO}:${PHP_MINOR} . |
19 | 16 | done |
20 | 17 |
|
21 | 18 | for PHP_VERSION in $(echo "$PHP_TAGS"); do |
22 | 19 | echo "##### Build $PHP_VERSION (x.y.z) #####" |
23 | | - docker build --build-arg PHP_VERSION_TAG=${PHP_VERSION}-apache -f ${DOCKERFILE_PATH} -t ${DOCKER_REPO}:${PHP_VERSION}-latest . |
| 20 | + docker build --build-arg PHP_VERSION_TAG=${PHP_VERSION}-apache -f ${DOCKERFILE_PATH} -t ${DOCKER_REPO}:${PHP_VERSION} . |
24 | 21 | done |
25 | 22 |
|
26 | 23 | else |
27 | 24 |
|
28 | | - # I think we kind of have to build that default ~UI~ box. Naming it x-* |
29 | | - docker build --build-arg PHP_VERSION_TAG=${PHP_VERSION_TAG} -f ${DOCKERFILE_PATH} -t ${DOCKER_REPO}:${DOCKER_TAG} . |
30 | | - |
31 | | - for PHP_MAJOR in $(echo "$PHP_TAGS" | grep -Po "^[0-9]+" | sort | uniq); do |
32 | | - echo "##### Build ${PHP_MAJOR}-${DOCKER_TAG} (phpVersion-basePhpApacheVersion) #####" |
33 | | - docker build --build-arg PHP_VERSION_TAG=${PHP_MAJOR}-apache -f ${DOCKERFILE_PATH} -t ${DOCKER_REPO}:${PHP_MAJOR}-${DOCKER_TAG} . |
34 | | - done |
| 25 | + CURRENT_RELEASE=$(echo $SOURCE_BRANCH | cut -c2-) |
35 | 26 |
|
36 | 27 | for PHP_MINOR in $(echo "$PHP_TAGS" | grep -Po "^[0-9]+\.[0-9]+" | sort | uniq); do |
37 | | - echo "##### Build ${PHP_MINOR}-latest (x.y-latest) #####" |
38 | | - docker build --build-arg PHP_VERSION_TAG=${PHP_MINOR}-apache -f ${DOCKERFILE_PATH} -t ${DOCKER_REPO}:${PHP_MINOR}-${DOCKER_TAG} . |
| 28 | + SHORT_DOCKER_TAG=$(echo $CURRENT_RELEASE | cut -d'.' -f-2) |
| 29 | + CUSTOM_IMAGE_NAME="${DOCKER_REPO}:php${PHP_MINOR}-v${SHORT_DOCKER_TAG}" |
| 30 | + echo "##### Build $CUSTOM_IMAGE_NAME #####" |
| 31 | + docker build --build-arg PHP_VERSION_TAG=${PHP_MINOR}-apache -f ${DOCKERFILE_PATH} -t ${CUSTOM_IMAGE_NAME} . |
39 | 32 | done |
40 | 33 |
|
41 | 34 | for PHP_VERSION in $(echo "$PHP_TAGS"); do |
42 | | - echo "##### Build $PHP_VERSION (x.y.z) #####" |
43 | | - docker build --build-arg PHP_VERSION_TAG=${PHP_VERSION}-apache -f ${DOCKERFILE_PATH} -t ${DOCKER_REPO}:${PHP_VERSION}-${DOCKER_TAG} . |
| 35 | + CUSTOM_IMAGE_NAME="${DOCKER_REPO}:php${PHP_VERSION}-v${CURRENT_RELEASE}" |
| 36 | + echo "##### Build $CUSTOM_IMAGE_NAME #####" |
| 37 | + docker build --build-arg PHP_VERSION_TAG=${PHP_VERSION}-apache -f ${DOCKERFILE_PATH} -t ${CUSTOM_IMAGE_NAME} . |
44 | 38 | done |
45 | 39 |
|
46 | 40 | fi |
0 commit comments