Skip to content

Commit 1cc5374

Browse files
committed
Gitlab ci Test and build for multiarch
1 parent d573095 commit 1cc5374

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+424
-478
lines changed

.github/workflows/workflow.yml

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,84 @@ on:
1111
- cron: '42 3 * * 0'
1212

1313
jobs:
14-
build_test_maybe_release:
14+
build:
1515
strategy:
16+
fail-fast: false
1617
matrix:
1718
php_version: ['8.1','8.0','7.4', '7.3','7.2']
1819
variant: ['apache','cli','fpm']
19-
runs-on: ubuntu-latest
20+
builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "macos-latest"}]
21+
# builder: [ {arch: "amd64", os: "self-hosted"}, {arch: "arm64", os: "self-hosted"}]
22+
runs-on: ${{ matrix.builder.os }}
23+
# runs-on: self-hosted
24+
name: Build & test ${{ matrix.php_version }}-${{ matrix.variant }} (${{ matrix.builder.arch }})
2025
steps:
2126
- name: Checkout
2227
uses: actions/checkout@v3
28+
- name: Set up Docker
29+
# /!\ this action is marked as experimental
30+
# It's required only for macos
31+
if: ${{ matrix.builder.os == 'macos-latest' }}
32+
uses: docker-practice/actions-setup-docker@master
2333
- name: Set up QEMU
2434
uses: docker/setup-qemu-action@v2
2535
- name: Set up Docker Buildx
2636
uses: docker/setup-buildx-action@v2
27-
- name: Build locally (amd64)
37+
- name: Expose GitHub Runtime for docker cache
38+
uses: crazy-max/ghaction-github-runtime@v2
39+
- name: Build
2840
run: |
2941
PHP_VERSION="${{ matrix.php_version }}"
30-
docker buildx bake --load \
31-
--set "*.platform=linux/amd64" \
42+
TAG_PREFIX="rc-${{ env.GITHUB_SHA_SHORT }}-" \
43+
docker buildx bake \
44+
--set "*.platform=linux/${{ matrix.builder.arch }}" \
45+
--set "*.output=type=docker" \
3246
php${PHP_VERSION//.}-${{ matrix.variant }}-all
33-
# Fetch minor version
34-
PHP_VERSION_MINOR=`docker run --rm thecodingmachine/php:${PHP_VERSION}-v4-slim-${{ matrix.variant }} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1`
35-
echo "PHP_VERSION_MINOR=${PHP_VERSION_MINOR}" >> $GITHUB_ENV
36-
# Summary
37-
echo "PHP Version : ${PHP_VERSION_MINOR}" >> $GITHUB_STEP_SUMMARY
38-
docker images --filter=reference=thecodingmachine/php >> $GITHUB_STEP_SUMMARY
39-
docker images --filter=reference=thecodingmachine/php
40-
- name: Test variant '${{ matrix.variant }}' (amd64)
41-
run: |
42-
PHP_VERSION="${{ matrix.php_version }}" BRANCH=v4 VARIANT=${{ matrix.variant }} ./tests-suite/bash_unit -f tap ./tests-suite/*.sh
47+
- name: Test
48+
run: |
49+
TAG_PREFIX="rc-${{ env.GITHUB_SHA_SHORT }}-" \
50+
PHP_VERSION="${{ matrix.php_version }}" BRANCH=v4 VARIANT=${{ matrix.variant }} PLATFORM=linux/${{ matrix.builder.arch }} ./tests-suite/bash_unit -f tap ./tests-suite/*.sh
51+
52+
publish:
53+
# push ~ schedule
54+
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
55+
needs:
56+
- build
57+
runs-on: ubuntu-latest
58+
name: Publish multi-arch to dockerhub
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
php_version: ['8.1'] #,'8.0','7.4', '7.3','7.2']
63+
variant: ['apache'] #,'cli','fpm']
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v3
67+
- name: Set up QEMU
68+
uses: docker/setup-qemu-action@v2
69+
- name: Set up Docker Buildx
70+
uses: docker/setup-buildx-action@v2
71+
- name: Expose GitHub Runtime for docker cache
72+
uses: crazy-max/ghaction-github-runtime@v2
4373
- name: Login to DockerHub
44-
# Merge ~ push.
45-
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
4674
uses: docker/login-action@v1
4775
with:
4876
username: ${{ secrets.DOCKERHUB_USERNAME }}
4977
password: ${{ secrets.DOCKERHUB_TOKEN }}
50-
- name: Build and push to repository (both amd64 and arm64)
51-
# Merge ~ push.
52-
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
78+
- name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }} as multiarch (amd64 and arm64)
5379
run: |
80+
TAG_PREFIX="rc-${{ env.GITHUB_SHA_SHORT }}-" \
81+
docker buildx bake \
82+
--set "*.cache-from=type=gha" \
83+
--set "*.platform=linux/amd64,linux/arm64" \
84+
--set "*.output=type=registry" \
85+
php${PHP_VERSION//.}-slim-${{ matrix.variant }}
86+
PHP_PATCH_MINOR=`docker run --rm thecodingmachine/php:rc-${{ env.GITHUB_SHA_SHORT }}-${{ matrix.php_version }}-v4-slim-${{ matrix.variant }} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1`
5487
PHP_VERSION="${{ matrix.php_version }}"
88+
TAG_PREFIX="rc-${{ env.GITHUB_SHA_SHORT }}-" \
5589
PHP_PATCH_MINOR="${{ env.PHP_VERSION_MINOR }}" \
5690
docker buildx bake \
91+
--set "*.cache-from=gha" \
5792
--set "*.platform=linux/amd64,linux/arm64" \
5893
--set "*.output=type=registry" \
5994
php${PHP_VERSION//.}-${{ matrix.variant }}-all

Dockerfile.apache

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
#syntax=docker/dockerfile-upstream:1
12
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
23
ARG INSTALL_CRON=1
34
ARG INSTALL_COMPOSER=1
45
ARG PHP_VERSION
56
ARG GLOBAL_VERSION
7+
ARG REPO="thecodingmachine/php"
8+
ARG TAG_PREFIX=""
69

7-
ARG FROM_IMAGE="thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-apache"
10+
ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}${PHP_VERSION}-${GLOBAL_VERSION}-slim-apache"
811
FROM $FROM_IMAGE
912
LABEL authors="Julien Neuhart <[email protected]>, David Négrier <[email protected]>"
13+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
1014

1115
ARG TARGETOS
1216
ARG TARGETARCH

Dockerfile.apache.node14 renamed to Dockerfile.apache.node

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1+
#syntax=docker/dockerfile-upstream:1
12
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
2-
ARG FROM_IMAGE="thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache"
3+
ARG REPO="thecodingmachine/php"
4+
ARG TAG_PREFIX=""
5+
ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}:${PHP_VERSION}-${GLOBAL_VERSION}-apache"
36
FROM $FROM_IMAGE
47
LABEL authors="Julien Neuhart <[email protected]>, David Négrier <[email protected]>"
8+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
59

610
ARG TARGETOS
711
ARG TARGETARCH
812
ARG BLACKFIRE_VERSION=1
13+
ARG NODE_VERSION=16
914

1015
USER root
1116

1217
ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
1318

1419
RUN apt-get update && \
1520
apt-get install -y --no-install-recommends gnupg && \
16-
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
21+
curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
1722
apt-get update && \
1823
apt-get install -y --no-install-recommends nodejs && \
1924
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
2025
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
2126
apt-get update && \
2227
apt-get install -y --no-install-recommends yarn && \
23-
npm install -g npm && \
28+
if [[ "${NODE_VERSION}" == "10" ]]; then npm install -g npm@^6.14; else npm install -g npm; fi && \
2429
apt-get clean && \
2530
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
2631

Dockerfile.apache.node16

Lines changed: 0 additions & 27 deletions
This file was deleted.

Dockerfile.cli

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
#syntax=docker/dockerfile-upstream:1
12
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
23
ARG INSTALL_CRON=1
34
ARG INSTALL_COMPOSER=1
45
ARG PHP_VERSION
56
ARG GLOBAL_VERSION
7+
ARG REPO="thecodingmachine/php"
8+
ARG TAG_PREFIX=""
69

7-
ARG FROM_IMAGE="thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-cli"
10+
ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}${PHP_VERSION}-${GLOBAL_VERSION}-slim-cli"
811
FROM $FROM_IMAGE
912
LABEL authors="Julien Neuhart <[email protected]>, David Négrier <[email protected]>"
13+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
1014

1115
ARG TARGETOS
1216
ARG TARGETARCH

Dockerfile.apache.node10 renamed to Dockerfile.cli.node

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1+
#syntax=docker/dockerfile-upstream:1
12
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
2-
ARG FROM_IMAGE="thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache"
3+
ARG REPO="thecodingmachine/php"
4+
ARG TAG_PREFIX=""
5+
ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}:${PHP_VERSION}-${GLOBAL_VERSION}-cli"
36
FROM $FROM_IMAGE
47
LABEL authors="Julien Neuhart <[email protected]>, David Négrier <[email protected]>"
8+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
59

610
ARG TARGETOS
711
ARG TARGETARCH
812
ARG BLACKFIRE_VERSION=1
13+
ARG NODE_VERSION=16
914

1015
USER root
1116

1217
ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
1318

1419
RUN apt-get update && \
1520
apt-get install -y --no-install-recommends gnupg && \
16-
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
21+
curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
1722
apt-get update && \
1823
apt-get install -y --no-install-recommends nodejs && \
1924
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
2025
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
2126
apt-get update && \
2227
apt-get install -y --no-install-recommends yarn && \
23-
npm install -g npm@^6.14 && \
28+
if [[ "${NODE_VERSION}" == "10" ]]; then npm install -g npm@^6.14; else npm install -g npm; fi && \
2429
apt-get clean && \
2530
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
2631

Dockerfile.cli.node10

Lines changed: 0 additions & 27 deletions
This file was deleted.

Dockerfile.cli.node12

Lines changed: 0 additions & 27 deletions
This file was deleted.

Dockerfile.cli.node14

Lines changed: 0 additions & 27 deletions
This file was deleted.

Dockerfile.cli.node16

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)