Skip to content

Fix multiarch + Add bash_unit for testing #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Sep 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/.git*
/docker-bake.hcl
/Dockerfile.*
/Makefile
/*.md
/LICENSE
/orbit*
/test*
/utils/*.blueprint.*
/utils/*.blueprint
117 changes: 85 additions & 32 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -7,59 +7,112 @@ on:
push:
branches:
- 'v4'
# schedule:
# - cron: '42 3 * * 0'
schedule:
- cron: '42 3 * * 0'

jobs:
build_test_maybe_release:
test:
strategy:
fail-fast: false
matrix:
php_version: ['8.1','8.0','7.4', '7.3','7.2']
variant: ['apache','cli','fpm']
runs-on: ubuntu-latest
# builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "macos-latest"}]
builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "ubuntu-latest"}]
runs-on: ${{ matrix.builder.os }}
name: Test ${{ matrix.php_version }}-${{ matrix.variant }} ${{ matrix.builder.arch }} only
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker
# /!\ this action is marked as experimental
# It's required only for macos
if: ${{ matrix.builder.os == 'macos-latest' }}
uses: docker-practice/actions-setup-docker@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
- name: Build
run: |
PHP_VERSION="${{ matrix.php_version }}"
TAG_PREFIX="rc${GITHUB_SHA::7}-" \
docker buildx bake \
--set "*.platform=linux/${{ matrix.builder.arch }}" \
--set "*.output=type=docker" \
--load \
php${PHP_VERSION//.}-${{ matrix.variant }}-all
- name: Display tags built
run: |
docker image ls --filter="reference=thecodingmachine/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}"
- name: Test
run: |
TAG_PREFIX="rc${GITHUB_SHA::7}-" \
PHP_VERSION="${{ matrix.php_version }}" \
BRANCH="v4" \
VARIANT="${{ matrix.variant }}" \
PLATFORM="linux/${{ matrix.builder.arch }}" \
./tests-suite/bash_unit -f tap ./tests-suite/*.sh

publish:
# push ~ schedule
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
needs:
- test
runs-on: ubuntu-latest
name: Publish ${{ matrix.php_version }}-${{ matrix.variant }} multi-arch to dockerhub
strategy:
fail-fast: false
matrix:
php_version: ['8.1','8.0','7.4', '7.3','7.2']
variant: ['apache','cli','fpm']
steps:
- name: Checkout
uses: actions/checkout@v1
# - name: Build locally
# run: |
# PHP_VERSION="${{ matrix.php_version }}"
# docker buildx bake --load \
# --set "*.platform=linux/amd64" \
# php${PHP_VERSION//.}-slim-${{ matrix.variant }}
# docker buildx bake --load \
# --set "*.platform=linux/amd64" \
# php${PHP_VERSION//.}-${{ matrix.variant }}-all
# PHP_VERSION_MINOR=`docker run --rm thecodingmachine/php:${PHP_VERSION}-v4-slim-cli php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1`
# echo "PHP_VERSION_MINOR=${PHP_VERSION_MINOR}" >> $GITHUB_ENV
# echo "PHP Version : ${PHP_VERSION_MINOR}" >> $GITHUB_STEP_SUMMARY
# docker images --filter=reference=thecodingmachine/php >> $GITHUB_STEP_SUMMARY
# - name: Test ${{ matrix.variant }}
# run: |
# PHP_VERSION="${{ matrix.php_version }}" BRANCH=v4 VARIANT=${{ matrix.variant }} ./test-image.sh
# echo "${{ matrix.variant }} variant OK" >> $GITHUB_STEP_SUMMARY
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
# Merge ~ push.
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push to repository
# Merge ~ push.
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
- name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }} with tagged prefix
run: |
PHP_VERSION="${{ matrix.php_version }}"
TAG_PREFIX="rc${GITHUB_SHA::7}-" \
docker buildx bake \
--set "*.platform=linux/amd64,linux/arm64" \
--set "*.output=type=registry" \
php${PHP_VERSION//.}-slim-${{ matrix.variant }}
PHP_PATCH_MINOR=`docker run --rm thecodingmachine/php:${PHP_VERSION}-v4-slim-cli php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` \
php${PHP_VERSION//.}-${{ matrix.variant }}-all
- name: Fetch minor version of php
run: |
# Retrieve minor version
PHP_PATCH_MINOR=`docker run --rm thecodingmachine/php:rc-${GITHUB_SHA::7}-${{ matrix.php_version }}-v4-slim-${{ matrix.variant }} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1`
echo "PHP_PATCH_MINOR=${PHP_PATCH_MINOR}" >> $GITHUB_ENV
- name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }} with releases tags (major and minor)
run: |
PHP_VERSION="${{ matrix.php_version }}"
PHP_PATCH_MINOR="${PHP_VERSION_MINOR}" \
docker buildx bake \
--set "*.platform=linux/amd64,linux/arm64" \
--set "*.output=type=registry" \
--metadata-file "/tmp/digests-php${PHP_VERSION//.}-${{ matrix.variant }}.log"
php${PHP_VERSION//.}-${{ matrix.variant }}-all
docker images --filter=reference=thecodingmachine/php >> $GITHUB_STEP_SUMMARY
- name: Artifacts
uses: actions/upload-artifact@v3
with:
name: digests-${{ matrix.php_version }}-${{ matrix.variant }}
path: /tmp/digests-php${PHP_VERSION//.}-${{ matrix.variant }}.log
retention-days: 60
- name: Display tags built
run: |
echo "With prefix :"
TAG_PREFIX="rc${GITHUB_SHA::7}-" \
docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --print --progress plain | jq ".target[].tags | join(\" \")" -r
echo "-----"
echo "Regular :"
PHP_PATCH_MINOR="${PHP_VERSION_MINOR}" \
docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --print --progress plain | jq ".target[].tags | join(\" \")" -r

3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.idea
tmp
.idea
7 changes: 6 additions & 1 deletion Dockerfile.apache
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#syntax=docker/dockerfile-upstream:1
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
ARG INSTALL_CRON=1
ARG INSTALL_COMPOSER=1
ARG PHP_VERSION
ARG GLOBAL_VERSION
ARG REPO="thecodingmachine/php"
ARG TAG_PREFIX=""

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

ARG TARGETOS
ARG TARGETARCH
12 changes: 9 additions & 3 deletions Dockerfile.apache.node14 → Dockerfile.apache.node
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
#syntax=docker/dockerfile-upstream:1
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache as baseapp
ARG REPO="thecodingmachine/php"
ARG TAG_PREFIX=""
ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}:${PHP_VERSION}-${GLOBAL_VERSION}-apache"
FROM $FROM_IMAGE
LABEL authors="Julien Neuhart <[email protected]>, David Négrier <[email protected]>"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

ARG TARGETOS
ARG TARGETARCH
ARG BLACKFIRE_VERSION=1
ARG NODE_VERSION=16

USER root

ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION}

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

26 changes: 0 additions & 26 deletions Dockerfile.apache.node16

This file was deleted.

7 changes: 6 additions & 1 deletion Dockerfile.cli
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#syntax=docker/dockerfile-upstream:1
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
ARG INSTALL_CRON=1
ARG INSTALL_COMPOSER=1
ARG PHP_VERSION
ARG GLOBAL_VERSION
ARG REPO="thecodingmachine/php"
ARG TAG_PREFIX=""

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

ARG TARGETOS
ARG TARGETARCH
12 changes: 9 additions & 3 deletions Dockerfile.apache.node10 → Dockerfile.cli.node
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
#syntax=docker/dockerfile-upstream:1
# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)
FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache as baseapp
ARG REPO="thecodingmachine/php"
ARG TAG_PREFIX=""
ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}:${PHP_VERSION}-${GLOBAL_VERSION}-cli"
FROM $FROM_IMAGE
LABEL authors="Julien Neuhart <[email protected]>, David Négrier <[email protected]>"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

ARG TARGETOS
ARG TARGETARCH
ARG BLACKFIRE_VERSION=1
ARG NODE_VERSION=16

USER root

ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION}

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

26 changes: 0 additions & 26 deletions Dockerfile.cli.node10

This file was deleted.

26 changes: 0 additions & 26 deletions Dockerfile.cli.node12

This file was deleted.

26 changes: 0 additions & 26 deletions Dockerfile.cli.node14

This file was deleted.

Loading