-
Notifications
You must be signed in to change notification settings - Fork 50
136 lines (109 loc) · 6.26 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Docker Build & Release
on:
workflow_dispatch:
push:
tags:
- 'v*.*'
schedule:
- cron: '30 2 * * 1,3,5'
env:
IMAGE_NAME: pimcore/pimcore
jobs:
build-php:
name: "Build PHP images"
runs-on: ubuntu-latest
if: github.repository == 'pimcore/docker'
strategy:
matrix:
include:
- { tag: '1.x', php: '8.0', distro: bullseye, version-override: "v1-dev", latest-tag: false }
- { tag: '1.x', php: '8.1', distro: bullseye, version-override: "v1-dev", latest-tag: false }
- { tag: '1.x', php: '8.2', distro: bullseye, version-override: "v1-dev", latest-tag: false }
- { tag: 'v1.3', php: '8.0', distro: bullseye, version-override: "", latest-tag: true }
- { tag: 'v1.3', php: '8.1', distro: bullseye, version-override: "", latest-tag: true }
- { tag: 'v1.3', php: '8.2', distro: bullseye, version-override: "", latest-tag: false }
- { tag: 'v2.0', php: '8.2', distro: bullseye, version-override: "", latest-tag: false }
- { tag: '2.x', php: '8.2', distro: bullseye, version-override: "v2-dev", latest-tag: false }
- { tag: 'v3.5', php: '8.2', distro: bookworm, version-override: "", latest-tag: true }
- { tag: 'v3.5', php: '8.3', distro: bookworm, imagick_version_from_src: 28f27044e435a2b203e32675e942eb8de620ee58, version-override: "", latest-tag: true }
- { tag: '3.x', php: '8.2', distro: bookworm, version-override: "v3-dev", latest-tag: false }
- { tag: '3.x', php: '8.3', distro: bookworm, imagick_version_from_src: 28f27044e435a2b203e32675e942eb8de620ee58, version-override: "v3-dev", latest-tag: false }
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.tag }}
- name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.tag }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.tag }}-
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: 'amd64,arm64'
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Configure and build images
id: vars
env:
VERSION_OVERRIDE: "${{ matrix.version-override }}"
run: |
set -eux;
if [[ "${{ matrix.tag }}" =~ ^v?1.[0-9x]+$ ]]; then
imageVariants=("fpm" "debug" "supervisord")
else
imageVariants=("min" "default" "max" "debug" "supervisord")
fi
for imageVariant in ${imageVariants[@]}; do
echo "Building image variant $imageVariant"
DOCKER_PLATFORMS=linux/amd64,linux/arm64
PHP_VERSION=${{ matrix.php }}
DEBIAN_VERSION="${{ matrix.distro }}"
VERSION="${{ matrix.tag }}"
# for the latest dev branch we use "dev" as the version and not the name of the branch
if [ ! -z "$VERSION_OVERRIDE" ]; then
VERSION="$VERSION_OVERRIDE"
fi
PHP_SUB_VERSION=$(docker run -i --rm php:${{ matrix.php }}-fpm-${{ matrix.distro }} php -r 'echo PHP_VERSION;')
if [ "$imageVariant" = "fpm" ] || [ "$imageVariant" = "default" ]; then
BASE_TAG="php${{ matrix.php }}"
BASE_TAG_DETAILED="php${PHP_SUB_VERSION}"
else
BASE_TAG="php${{ matrix.php }}-$imageVariant"
BASE_TAG_DETAILED="php${PHP_SUB_VERSION}-$imageVariant"
fi
# DEBUG / TEST
#BASE_TAG="testv3-$BASE_TAG"
#BASE_TAG_DETAILED="testv3-$BASE_TAG_DETAILED"
TAG="${BASE_TAG}-${VERSION}"
TAG_DETAILED="${BASE_TAG_DETAILED}-${VERSION}"
TAGS="--tag ${IMAGE_NAME}:${TAG}"
TAGS="$TAGS --tag ${IMAGE_NAME}:${TAG_DETAILED}"
# Tag latest with Version build too
if [ "true" = "${{ matrix.latest-tag }}" ]; then
TAGS="$TAGS --tag ${IMAGE_NAME}:${BASE_TAG}-latest"
fi
# Create tag for major version
if [[ $VERSION =~ ^v[0-9]+.[0-9]+$ ]]; then
VERSION_MAJOR=${VERSION//.[0-9]/}
TAGS="$TAGS --tag ${IMAGE_NAME}:${BASE_TAG}-${VERSION_MAJOR}"
fi
echo ${TAGS}
docker buildx build --output "type=image,push=true" --platform ${DOCKER_PLATFORMS} \
--target="pimcore_php_$imageVariant" \
--build-arg PHP_VERSION="${PHP_VERSION}" \
--build-arg DEBIAN_VERSION="${DEBIAN_VERSION}" \
--build-arg IMAGICK_VERSION_FROM_SRC="${{ matrix.imagick_version_from_src }}" \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache-new" \
${TAGS} .
docker buildx imagetools inspect ${IMAGE_NAME}:${TAG} || true;
done
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache