Skip to content

Commit

Permalink
Update build workflows and versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
nbejansen committed Feb 6, 2024
1 parent 85910ba commit 53bfee1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
32 changes: 20 additions & 12 deletions .github/workflows/build-and-test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,28 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get version from branch name
run: |
export BRANCH=${GITHUB_REF##*/}
echo "VERSION=v${BRANCH/.x/}" >> $GITHUB_ENV
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/sitepilot/php-${{ inputs.target }}
tags: |
type=ref,event=branch,prefix=${{ matrix.php }}
type=ref,event=pr,prefix=${{ matrix.php }}
type=semver,pattern={{version}},prefix=${{ matrix.php }}
type=semver,pattern={{major}},prefix=${{ matrix.php }}
type=semver,pattern={{major}}.{{minor}},prefix=${{ matrix.php }}
- name: Build test image
uses: docker/build-push-action@v5
with:
context: ./src
load: true
pull: true
tags: ghcr.io/sitepilot/php-${{ inputs.target }}:build
target: ${{ inputs.target }}
cache-from: type=gha,scope=php-${{ inputs.target }}-${{ env.VERSION }}-${{ matrix.php }}
tags: ghcr.io/sitepilot/php-${{ inputs.target }}:build
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PHP_VERSION=${{ matrix.php }}
Expand All @@ -60,13 +68,13 @@ jobs:
uses: docker/build-push-action@v5
with:
context: ./src
target: ${{ inputs.target }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/sitepilot/php-${{ inputs.target }}:${{ matrix.php }}
ghcr.io/sitepilot/php-${{ inputs.target }}:${{ env.VERSION }}-${{ matrix.php }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64, linux/arm64
target: ${{ inputs.target }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
cache-to: type=gha,mode=max,scope=php-${{ inputs.target }}-${{ env.VERSION }}-${{ matrix.php }}
build-args: |
PHP_VERSION=${{ matrix.php }}
11 changes: 5 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ name: build
on:
push:
branches:
- 1.x
paths:
- 'src/**'
schedule:
- cron: '25 4 * * *'
- '1.x'
tags:
- 'v*'
pull_request:
workflow_dispatch:
branches:
- '1.x'

jobs:
php-cli:
Expand Down
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,30 @@ For example, if you wish to run **PHP 8.2** with **FPM** & **NGINX**, use the fo
ghcr.io/sitepilot/php-nginx:8.1
```

## Customize an image
### Customization

To customize an image and avoid potential breaking changes in your container builds, use the following image naming
pattern in your Dockerfile:
To use this image as a base image and avoid potential breaking changes in your container builds, use the following
image naming pattern in your `Dockerfile`:

```Dockerfile
FROM ghcr.io/sitepilot/php-{{variation-name}}:{{runtime-version}}-{{php-version}}
FROM ghcr.io/sitepilot/php-{{variation-name}}:{{php-version}}-{{release-version}}
```

For example, if you wish to customize the **PHP 8.2** with **FPM** & **NGINX** image, which is built upon
the [Runtime V1](https://github.com/sitepilot/docker-runtime/tree/1.x) image (Ubuntu 22.04 LTS), include the
following `FROM` line in your Dockerfile:
The images are tagged according to Semantic Versioning (SemVer). Available releases can be found on the [releases page](https://github.com/sitepilot/docker-php/releases). For example, if you wish to customize version 1.x of the image:

```Dockerfile
FROM ghcr.io/sitepilot/php-nginx:v1-8.2
# Guaranteed backward compatibility, new features and bug fixes.
FROM ghcr.io/sitepilot/php-nginx:8.2-1
```

```Dockerfile
# Guaranteed backward compatibility and bug fixes.
FROM ghcr.io/sitepilot/php-nginx:8.2-1.0
```

```Dockerfile
# Guaranteed backward compatibility and no updates.
FROM ghcr.io/sitepilot/php-nginx:8.2-1.0.0
```

## Variations
Expand Down
2 changes: 1 addition & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# --------------- [PHP-CLI] --------------- #

FROM ghcr.io/sitepilot/runtime:v1 AS cli
FROM ghcr.io/sitepilot/runtime:1 AS cli

USER root

Expand Down

0 comments on commit 53bfee1

Please sign in to comment.