Skip to content
Merged
Show file tree
Hide file tree
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
160 changes: 135 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,152 @@ on:
tags: [ '*.*.*' ]
pull_request:
branches: [ master ]

env:
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

workflow_dispatch:
inputs:
push:
description: 'Push Image (true or false)'
type: choice
options:
- "true"
- "false"
required: true

jobs:
Build:
runs-on: 'ubuntu-latest'
container:
image: 'byjg/k8s-ci:latest'
options: --privileged -v /tmp/z:/var/lib/containers
strategy:
matrix:
include:
- php-version: "8.5"
architeture: "arm64,amd64"
- php-version: "8.4"
architeture: "arm64,amd64"
- php-version: "8.3"
architeture: "arm64,amd64"
- php-version: "5.6"
architeture: "arm64,amd64"
php-version:
- "8.5"
- "8.4"
- "8.3"
- "8.2"

steps:
- name: Get current date
run: |
echo "YEAR=$(date +'%Y')" >> $GITHUB_ENV
echo "MONTH=$(date +'%m')" >> $GITHUB_ENV

- uses: actions/checkout@v4

- name: Install requirements
run: pip install -r requirements.txt
- name: Login repository
run: buildah login --username ${{ secrets.DOCKER_REGISTRY_USER }} --password ${{ secrets.DOCKER_REGISTRY_TOKEN }} ${{ secrets.DOCKER_REGISTRY }}
- name: Building and Push PHP
run: python3 ./build.py ${{ matrix.php-version }} --arch ${{ matrix.architeture }} --build-base --build-cli --build-fpm --build-fpm-apache --build-fpm-nginx --build-nginx --push --debug
if: github.event_name != 'pull_request'
- name: Building PHP
run: python3 ./build.py ${{ matrix.php-version }} --arch ${{ matrix.architeture }} --build-base --build-cli --build-fpm --build-fpm-apache --build-fpm-nginx --build-nginx --debug
if: github.event_name == 'pull_request'

# - name: Set up Docker
# uses: docker/setup-docker-action@v4
# with:
# daemon-config: |
# {
# "debug": true,
# "features": {
# "containerd-snapshotter": true
# }
# }

- name: Log into registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Generate Dockerfiles
run: python3 ./build.py ${{ matrix.php-version }} --build-base --build-cli --build-fpm --build-fpm-apache --build-fpm-nginx --build-nginx

- name: Build Docker image base
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile-php-${{ matrix.php-version }}-base
platforms: linux/amd64,linux/arm64
push: false
tags: |
byjg/php:${{ matrix.php-version }}-base,
byjg/php:${{ matrix.php-version }}-base-${{ env.YEAR }}.${{ env.MONTH }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build Docker image cli
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile-php-${{ matrix.php-version }}-cli
platforms: linux/amd64,linux/arm64
push: false
tags: |
byjg/php:${{ matrix.php-version }}-cli,
byjg/php:${{ matrix.php-version }}-cli-${{ env.YEAR }}.${{ env.MONTH }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build Docker image fpm
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile-php-${{ matrix.php-version }}-fpm
platforms: linux/amd64,linux/arm64
push: false
tags: |
byjg/php:${{ matrix.php-version }}-fpm,
byjg/php:${{ matrix.php-version }}-fpm-${{ env.YEAR }}.${{ env.MONTH }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build Docker image fpm-apache
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile-php-${{ matrix.php-version }}-fpm-apache
platforms: linux/amd64,linux/arm64
push: false
tags: |
byjg/php:${{ matrix.php-version }}-fpm-apache,
byjg/php:${{ matrix.php-version }}-fpm-apache-${{ env.YEAR }}.${{ env.MONTH }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build Docker image fpm-nginx
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile-php-${{ matrix.php-version }}-fpm-nginx
platforms: linux/amd64,linux/arm64
push: false
tags: |
byjg/php:${{ matrix.php-version }}-fpm-nginx,
byjg/php:${{ matrix.php-version }}-fpm-nginx-${{ env.YEAR }}.${{ env.MONTH }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build Docker image nginx
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile-php-${{ matrix.php-version }}-nginx
platforms: linux/amd64,linux/arm64
push: false
tags: |
byjg/php:${{ matrix.php-version }}-nginx,
byjg/php:${{ matrix.php-version }}-nginx-${{ env.YEAR }}.${{ env.MONTH }}
labels: ${{ steps.meta.outputs.labels }}

- name: Push all built images
if: ${{ github.event_name != 'pull_request' || github.event.inputs.push == 'true' }}
run: |
docker push byjg/php:${{ matrix.php-version }}-base
docker push byjg/php:${{ matrix.php-version }}-base-${{ env.YEAR }}.${{ env.MONTH }}
docker push byjg/php:${{ matrix.php-version }}-cli
docker push byjg/php:${{ matrix.php-version }}-cli-${{ env.YEAR }}.${{ env.MONTH }}
docker push byjg/php:${{ matrix.php-version }}-fpm
docker push byjg/php:${{ matrix.php-version }}-fpm-${{ env.YEAR }}.${{ env.MONTH }}
docker push byjg/php:${{ matrix.php-version }}-fpm-apache
docker push byjg/php:${{ matrix.php-version }}-fpm-apache-${{ env.YEAR }}.${{ env.MONTH }}
docker push byjg/php:${{ matrix.php-version }}-fpm-nginx
docker push byjg/php:${{ matrix.php-version }}-fpm-nginx-${{ env.YEAR }}.${{ env.MONTH }}
docker push byjg/php:${{ matrix.php-version }}-nginx
docker push byjg/php:${{ matrix.php-version }}-nginx-${{ env.YEAR }}.${{ env.MONTH }}

Documentation:
if: github.ref == 'refs/heads/master'
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.idea
*~
/.tmp.sh
/venv/
.venv/
.env
*.pyc
Dockerfile-php-*
/examples/php/vendor/
/examples/php/composer.lock
26 changes: 26 additions & 0 deletions .run/Build Dockerfile.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build Dockerfile" type="PythonConfigurationType" factoryName="Python">
<module name="docker-php" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="SDK_NAME" value="Python 3.12 (docker-php)" />
<option name="WORKING_DIRECTORY" value="" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/build.py" />
<option name="PARAMETERS" value="8.3 --build-base --build-cli --build-fpm --build-fpm-apache --build-fpm-nginx --build-nginx" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>
27 changes: 0 additions & 27 deletions .run/Build PHP 8.1 base.run.xml

This file was deleted.

27 changes: 0 additions & 27 deletions .run/Build PHP 8.2 base.run.xml

This file was deleted.

27 changes: 0 additions & 27 deletions .run/Build PHP 8.3 base.run.xml

This file was deleted.

27 changes: 0 additions & 27 deletions .run/Build PHP 8.4 base.run.xml

This file was deleted.

17 changes: 0 additions & 17 deletions .run/Clean up Containers.run.xml

This file was deleted.

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ The PHP images are ready to use in:

| Version | Latest Version | Monthly Builds | Alpine Version |
|:-------:|:--------------:|:--------------:|:--------------:|
| **8.4** | **8.4.5** | **yes** | **edge** |
| **8.3** | **8.3.18** | **yes** | **edge** |
| **8.2** | **8.2.28** | **yes** | **edge** |
| **8.5** | **8.5.0RC2** | **yes** | **edge** |
| **8.4** | **8.4.13** | **yes** | **edge** |
| **8.3** | **8.3.26** | **yes** | **edge** |
| **8.2** | **8.2.29r2** | **yes** | **edge** |
| 8.1 | 8.1.31 | - | 3.19 |
| 8.0 | 8.0.30 | - | 3.16 |
| 7.4 | 7.4.33 | - | 3.15 |
Expand Down
15 changes: 8 additions & 7 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse

import pathlib
import os
import sys

Expand Down Expand Up @@ -79,7 +79,7 @@
# Execute the parse_args() method
args = my_parser.parse_args()

gen = Generator(args.PHP_Version, args.Debug, args.push != "")


cmd_list = []
cmd_list.append(args.buildBase) if args.buildBase != "" else None
Expand All @@ -90,8 +90,9 @@
cmd_list.append(args.buildNginx) if args.buildNginx != "" else None

for cmd in cmd_list:
gen.manifest_create(cmd)
for arch in args.arch.split(","):
iid = getattr(gen, "build_" + cmd)(arch)
gen.manifest_add(iid, cmd, arch)
gen.manifest_push(cmd)
gen = Generator(args.PHP_Version, args.Debug, args.push != "")
image_name = getattr(gen, "build_" + cmd)()
dockerfile_content = gen.get_dockerfile_content()
dockerfile_name = gen.dockerfile_name()
print(f"docker build -t {image_name} -f {dockerfile_name} .")
pathlib.Path(dockerfile_name).write_text(dockerfile_content)
Loading