Skip to content

Commit 30dfa2d

Browse files
committed
[WIP] arm
1 parent 146a08f commit 30dfa2d

19 files changed

Lines changed: 3867 additions & 1812 deletions

File tree

.github/workflows/build.yaml

Lines changed: 3716 additions & 1700 deletions
Large diffs are not rendered by default.

build-local.sh

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,30 @@ PHP_VERSION=8.5
1111

1212
if [ "$#" -gt 0 ]; then
1313
PHP_VERSION=$1
14-
if [ ! -d "$ROOT_DIR/docker/php/$PHP_VERSION" ]; then
14+
if [ ! -d "docker/php/$PHP_VERSION" ]; then
1515
echo "PHP version $PHP_VERSION not found"
1616
exit 1
1717
fi
1818
fi
1919

2020
# alpine
21-
cd $ROOT_DIR/docker/php/$PHP_VERSION-alpine
22-
docker build -t webdevops/php:$PHP_VERSION-alpine .
23-
cd $ROOT_DIR/docker/php-dev/$PHP_VERSION-alpine
24-
docker build -t webdevops/php-dev:$PHP_VERSION-alpine .
21+
docker build -t webdevops/php:$PHP_VERSION-alpine docker/php/$PHP_VERSION-alpine
22+
docker build -t webdevops/php-dev:$PHP_VERSION-alpine docker/php-dev/$PHP_VERSION-alpine
2523

26-
cd $ROOT_DIR/docker/php-nginx/$PHP_VERSION-alpine
27-
docker build -t webdevops/php-nginx:$PHP_VERSION-alpine .
28-
cd $ROOT_DIR/docker/php-nginx-dev/$PHP_VERSION-alpine
29-
docker build -t webdevops/php-nginx-dev:$PHP_VERSION-alpine .
24+
docker build -t webdevops/php-nginx:$PHP_VERSION-alpine docker/php-nginx/$PHP_VERSION-alpine
25+
docker build -t webdevops/php-nginx-dev:$PHP_VERSION-alpine docker/php-nginx-dev/$PHP_VERSION-alpine
3026

31-
cd $ROOT_DIR/docker/php-apache/$PHP_VERSION-alpine
32-
docker build -t webdevops/php-apache:$PHP_VERSION-alpine .
33-
cd $ROOT_DIR/docker/php-apache-dev/$PHP_VERSION-alpine
34-
docker build -t webdevops/php-apache-dev:$PHP_VERSION-alpine .
27+
docker build -t webdevops/php-apache:$PHP_VERSION-alpine docker/php-apache/$PHP_VERSION-alpine
28+
docker build -t webdevops/php-apache-dev:$PHP_VERSION-alpine docker/php-apache-dev/$PHP_VERSION-alpine
3529

3630
# debian
37-
cd $ROOT_DIR/docker/php/$PHP_VERSION
38-
docker build -t webdevops/php:$PHP_VERSION .
39-
cd $ROOT_DIR/docker/php-dev/$PHP_VERSION
40-
docker build -t webdevops/php-dev:$PHP_VERSION .
41-
42-
cd $ROOT_DIR/docker/php-nginx/$PHP_VERSION
43-
docker build -t webdevops/php-nginx:$PHP_VERSION .
44-
cd $ROOT_DIR/docker/php-nginx-dev/$PHP_VERSION
45-
docker build -t webdevops/php-nginx-dev:$PHP_VERSION .
46-
47-
cd $ROOT_DIR/docker/php-apache/$PHP_VERSION
48-
docker build -t webdevops/php-apache:$PHP_VERSION .
49-
cd $ROOT_DIR/docker/php-apache-dev/$PHP_VERSION
50-
docker build -t webdevops/php-apache-dev:$PHP_VERSION .
31+
docker build -t webdevops/php:$PHP_VERSION docker/php/$PHP_VERSION
32+
docker build -t webdevops/php-dev:$PHP_VERSION docker/php-dev/$PHP_VERSION
33+
34+
docker build -t webdevops/php-nginx:$PHP_VERSION docker/php-nginx/$PHP_VERSION
35+
docker build -t webdevops/php-nginx-dev:$PHP_VERSION docker/php-nginx-dev/$PHP_VERSION
36+
37+
docker build -t webdevops/php-apache:$PHP_VERSION docker/php-apache/$PHP_VERSION
38+
docker build -t webdevops/php-apache-dev:$PHP_VERSION docker/php-apache-dev/$PHP_VERSION
5139

5240
docker images | grep webdevops | grep $PHP_VERSION

ci/src/Commands/GithubCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ private function traverse(Node $node): void
8585
if ($node->getLevel() > $this->deepestLevel) {
8686
$this->deepestLevel = $node->getLevel();
8787
}
88-
$this->jobs[GithubJobBuilder::toJobId($node->getId())] = $this->jobBuilder->getJobDescription($nodeAr);
88+
$this->jobs = [
89+
...$this->jobs,
90+
...$this->jobBuilder->getJobsDescription($nodeAr),
91+
];
8992
if ($this->isNameBlacklisted($nodeAr['id'])) {
9093
// $this->jobs[GithubJobBuilder::toJobId($node->getId())] = array_merge($this->jobs[GithubJobBuilder::toJobId($node->getId())], ['when' => 'manual']);
9194
$line .= ' *blacklisted*';
9295
if ($node->get('tag') !== $this->_settings['docker']['autoLatestTag']) {
9396
unset($this->jobs[GithubJobBuilder::toJobId($node->getId())]);
97+
unset($this->jobs[GithubJobBuilder::toJobId($node->getId()) . '_push']);
9498
}
9599
}
96100
$this->output->write([str_pad('', $node->getLevel() - 1, "\t", STR_PAD_LEFT), $line, PHP_EOL]);

ci/src/GithubJobBuilder.php

Lines changed: 104 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,125 @@
22

33
namespace Webdevops\Build;
44

5+
use function array_filter;
6+
use function array_values;
7+
use function dirname;
8+
use function implode;
59
use function str_replace;
610

711
class GithubJobBuilder
812
{
9-
10-
public function getJobDescription(array $node): array
13+
/**
14+
* @return array<string, array<string, mixed>>
15+
*/
16+
public function getJobsDescription(array $node): array
1117
{
1218
$serverSpec = $this->serverSpec($node);
1319
$structuredTests = $this->structuredTests($node);
1420

21+
$jobId = GithubJobBuilder::toJobId($node['name']);
1522
return [
16-
'name' => $node['name'],
17-
'needs' => [
18-
($node['parent'] ?? null) ? GithubJobBuilder::toJobId($node['parent']) : 'validate-automation',
19-
],
20-
'runs-on' => 'ubuntu-latest',
21-
'container' => 'webdevops/dockerfile-build-env',
22-
'steps' => array_values(
23-
array_filter(
24-
[
25-
['uses' => 'actions/checkout@v4'],
26-
// ['uses' => 'docker/setup-qemu-action@v3'], // only needed for ARM builds
27-
['uses' => 'docker/setup-buildx-action@v3'],
28-
[
29-
'name' => 'Build x64',
30-
'uses' => 'docker/build-push-action@v6',
31-
'with' => [
32-
'context' => dirname(str_replace(__DIR__ . '/../../', '', $node['file'])),
33-
'load' => true,
34-
'tags' => 'ghcr.io/webdevops/' . $node['image'] . ':' . $node['tag'] . ',webdevops/' . $node['image'] . ':' . $node['tag'],
35-
'platforms' => 'linux/amd64',
23+
$jobId => [
24+
'strategy' => [
25+
'fail-fast' => false,
26+
'matrix' => [
27+
'include' => [
28+
[
29+
'arch' => 'amd64',
30+
'runner' => 'ubuntu-latest',
31+
'platform' => 'linux/amd64',
3632
],
37-
],
38-
$serverSpec ? [
39-
'name' => 'run serverspec',
40-
'run' => implode("\n", $serverSpec),
41-
] : null,
42-
$structuredTests ? [
43-
'name' => 'run structure-test',
44-
'run' => implode("\n", $structuredTests),
45-
] : null,
46-
[
47-
'if' => '${{github.ref == \'refs/heads/master\'}}',
48-
'name' => 'Login to ghcr.io',
49-
'uses' => 'docker/login-action@v3',
50-
'with' => [
51-
'registry' => 'ghcr.io',
52-
'username' => '${{ github.actor }}',
53-
'password' => '${{ secrets.GITHUB_TOKEN }}',
33+
[
34+
'arch' => 'arm64',
35+
'runner' => 'ubuntu-latest', // 'ubuntu-24.04-arm' // only needed for ARM builds
36+
'platform' => 'linux/arm64',
5437
],
5538
],
39+
],
40+
],
41+
'name' => $node['name'] . ' (${{ matrix.arch }})',
42+
'needs' => ($node['parent'] ?? null) ? GithubJobBuilder::toJobId($node['parent']) : 'validate-automation',
43+
'runs-on' => '${{ matrix.runner }}',
44+
'container' => 'webdevops/dockerfile-build-env',
45+
'steps' => array_values(
46+
array_filter(
5647
[
57-
// login after the build so the rate limit of github is used and not from our login Token.
58-
'if' => '${{github.ref == \'refs/heads/master\'}}',
59-
'name' => 'Login to hub.docker.com',
60-
'uses' => 'docker/login-action@v3',
61-
'with' => [
62-
'username' => '${{ secrets.DOCKERHUB_USERNAME }}',
63-
'password' => '${{ secrets.DOCKERHUB_TOKEN }}',
48+
['uses' => 'actions/checkout@v6'],
49+
[
50+
'name' => 'Build (load locally)',
51+
'uses' => 'docker/build-push-action@v6',
52+
'with' => [
53+
'context' => dirname(str_replace(__DIR__ . '/../../', '', $node['file'])),
54+
'platforms' => '${{ matrix.platform }}',
55+
'load' => true,
56+
'tags' => 'ghcr.io/webdevops/' . $node['image'] . ':sha-${{ github.sha }}-${{ matrix.arch }}',
57+
'cache-from' => 'type=gha',
58+
'cache-to' => 'type=gha,mode=max',
59+
],
6460
],
65-
],
66-
[
67-
'if' => '${{github.ref == \'refs/heads/master\'}}',
68-
'name' => 'Push',
69-
// 'name' => 'Build ARM + Push',
70-
'uses' => 'docker/build-push-action@v6',
71-
'with' => [
72-
'context' => dirname(str_replace(__DIR__ . '/../../', '', $node['file'])),
73-
'push' => true,
74-
'tags' => 'ghcr.io/webdevops/' . $node['image'] . ':' . $node['tag'] . ',webdevops/' . $node['image'] . ':' . $node['tag'],
75-
'platforms' => 'linux/amd64',
76-
// 'platforms' => 'linux/amd64,linux/arm64', // ARM not ready yet
61+
$serverSpec ? [
62+
'name' => 'run serverspec',
63+
'run' => implode("\n", $serverSpec),
64+
] : null,
65+
$structuredTests ? [
66+
'name' => 'run structure-test',
67+
'run' => implode("\n", $structuredTests),
68+
] : null,
69+
[
70+
'if' => '${{github.ref == \'refs/heads/arm\'}}',
71+
'name' => 'Login to ghcr.io',
72+
'uses' => 'docker/login-action@v3',
73+
'with' => [
74+
'registry' => 'ghcr.io',
75+
'username' => '${{ github.actor }}',
76+
'password' => '${{ secrets.GITHUB_TOKEN }}',
77+
],
78+
],
79+
[
80+
'name' => 'Push arch image',
81+
'if' => '${{github.ref == \'refs/heads/arm\'}}',
82+
'run' => 'docker push "ghcr.io/webdevops/' . $node['image'] . ':sha-${{ github.sha }}-${{ matrix.arch }}"',
7783
],
7884
],
79-
],
85+
),
8086
),
81-
),
87+
],
88+
$jobId . '_push' => [
89+
'name' => $node['name'] . ' - Publish',
90+
'runs-on' => 'ubuntu-latest',
91+
'needs' => $jobId,
92+
'if' => '${{github.ref == \'refs/heads/arm\'}}',
93+
'steps' => [
94+
['uses' => 'docker/setup-buildx-action@v3'],
95+
[
96+
'name' => 'Login to ghcr.io',
97+
'uses' => 'docker/login-action@v3',
98+
'with' => [
99+
'registry' => 'ghcr.io',
100+
'username' => '${{ github.actor }}',
101+
'password' => '${{ secrets.GITHUB_TOKEN }}',
102+
],
103+
],
104+
[
105+
'name' => 'Login to hub.docker.com',
106+
'uses' => 'docker/login-action@v3',
107+
'with' => [
108+
'username' => '${{ secrets.DOCKERHUB_USERNAME }}',
109+
'password' => '${{ secrets.DOCKERHUB_TOKEN }}',
110+
],
111+
],
112+
[
113+
'name' => 'Create and push multi-arch manifest',
114+
'run' => implode(" \\\n", [
115+
'docker buildx imagetools create',
116+
'-t "webdevops/' . $node['image'] . ':' . $node['tag'] . '"',
117+
'-t "ghcr.io/webdevops/' . $node['image'] . ':' . $node['tag'] . '"',
118+
'"ghcr.io/webdevops/' . $node['image'] . ':sha-${{ github.sha }}-amd64"',
119+
'"ghcr.io/webdevops/' . $node['image'] . ':sha-${{ github.sha }}-arm64"',
120+
]),
121+
],
122+
],
123+
],
82124
];
83125
}
84126

@@ -98,14 +140,13 @@ private function serverSpec(array $node): array
98140
return [];
99141
}
100142

101-
// $testDockerfile = uniqid('Dockerfile_', true);
102143
$testDockerfile = 'Dockerfile_test';
103144
$specConfig = $node['serverspec'];
104145
$specConfig['DOCKERFILE'] = $testDockerfile;
105146
$encodedJsonConfig = base64_encode(json_encode($specConfig));
106147
$script = [
107148
'cd tests/serverspec',
108-
'echo "FROM ' . $node['id'] . '" >> ' . $testDockerfile,
149+
'echo "FROM ghcr.io/webdevops/' . $node['image'] . ':sha-${{ github.sha }}-${{ matrix.arch }}" >> ' . $testDockerfile,
109150
'echo "COPY conf/ /" >> ' . $testDockerfile,
110151
];
111152
$script[] = 'bundle install';
@@ -133,7 +174,7 @@ public function getValidationConfig(): array
133174
'name' => 'Validate Automation',
134175
'runs-on' => 'ubuntu-latest',
135176
'steps' => [
136-
['uses' => 'actions/checkout@v4'],
177+
['uses' => 'actions/checkout@v6'],
137178
[
138179
'name' => 'Validate that template/* are used to generate Dockerfiles',
139180
'run' => implode("\n", [

docker/dockerfile-build-env/latest/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#+++++++++++++++++++++++++++++++++++++++
55

66
FROM webdevops/base-app:ubuntu-22.04
7+
ARG TARGETARCH
78

89
RUN apt-install \
910
build-essential \
@@ -19,18 +20,20 @@ RUN apt-install \
1920
ruby \
2021
ruby-dev \
2122
ruby-bundler \
23+
libyaml-dev \
2224
&& curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py \
2325
&& python2 get-pip.py \
2426
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
25-
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
27+
&& add-apt-repository "deb [arch=$TARGETARCH] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
2628
&& apt-install docker-ce \
2729
&& usermod -aG docker application \
28-
&& curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 \
29-
&& chmod +x container-structure-test-linux-amd64 \
30-
&& mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test \
30+
&& curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-$TARGETARCH \
31+
&& chmod +x container-structure-test-linux-$TARGETARCH \
32+
&& mv container-structure-test-linux-$TARGETARCH /usr/local/bin/container-structure-test \
3133
&& pip install --upgrade pip \
3234
&& hash -r pip \
3335
&& pip install --upgrade setuptools \
36+
&& pip install Cython==0.29.21 wheel \
3437
&& git clone --depth 1 https://github.com/webdevops/Dockerfile.git /tmp/Dockerfile \
3538
&& gem install bundler -v 2.1.4 --no-document \
3639
&& cd /tmp/Dockerfile/tests/serverspec \

docker/dockerfile-build-env/latest/Dockerfile.jinja2

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{ docker.from("base-app","ubuntu-22.04") }}
2+
ARG TARGETARCH
23

34
RUN apt-install \
45
build-essential \
@@ -14,18 +15,20 @@ RUN apt-install \
1415
ruby \
1516
ruby-dev \
1617
ruby-bundler \
18+
libyaml-dev \
1719
&& curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py \
1820
&& python2 get-pip.py \
1921
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
20-
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
22+
&& add-apt-repository "deb [arch=$TARGETARCH] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
2123
&& apt-install docker-ce \
2224
&& usermod -aG docker application \
23-
&& curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 \
24-
&& chmod +x container-structure-test-linux-amd64 \
25-
&& mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test \
25+
&& curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-$TARGETARCH \
26+
&& chmod +x container-structure-test-linux-$TARGETARCH \
27+
&& mv container-structure-test-linux-$TARGETARCH /usr/local/bin/container-structure-test \
2628
&& pip install --upgrade pip \
2729
&& hash -r pip \
2830
&& pip install --upgrade setuptools \
31+
&& pip install Cython==0.29.21 wheel \
2932
&& git clone --depth 1 https://github.com/webdevops/Dockerfile.git /tmp/Dockerfile \
3033
&& gem install bundler -v 2.1.4 --no-document \
3134
&& cd /tmp/Dockerfile/tests/serverspec \

docker/php-official/5.6/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ RUN set -x \
141141
# Install extensions
142142
&& docker-php-ext-configure intl --with-icu-dir=/usr/local \
143143
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ \
144-
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
144+
&& docker-php-ext-configure ldap \
145145
&& PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
146146
&& docker-php-ext-install \
147147
bcmath \

docker/php-official/7.0/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ RUN set -x \
141141
# Install extensions
142142
&& docker-php-ext-configure intl --with-icu-dir=/usr/local \
143143
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ \
144-
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
144+
&& docker-php-ext-configure ldap \
145145
&& PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
146146
&& docker-php-ext-install \
147147
bcmath \

docker/php-official/7.1/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ RUN set -x \
141141
# Install extensions
142142
&& docker-php-ext-configure intl --with-icu-dir=/usr/local \
143143
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ \
144-
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
144+
&& docker-php-ext-configure ldap \
145145
&& PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
146146
&& docker-php-ext-install \
147147
bcmath \

docker/php-official/7.2/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ RUN set -x \
141141
# Install extensions
142142
&& docker-php-ext-configure intl --with-icu-dir=/usr/local \
143143
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ \
144-
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
144+
&& docker-php-ext-configure ldap \
145145
&& PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
146146
&& docker-php-ext-install \
147147
bcmath \

0 commit comments

Comments
 (0)