-
Notifications
You must be signed in to change notification settings - Fork 1
144 lines (130 loc) · 5.63 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Docker Build
on: push
env:
TEST_TAG: ${{ github.repository }}:test
jobs:
build:
name: Build ${{ matrix.php_version }}-composer${{ matrix.composer_version }}
runs-on: ubuntu-latest
strategy:
matrix:
php_version: ["7.4", "8.0", "8.1", "8.2", "8.3"]
composer_version: ["1", "2"]
platforms: ["linux/amd64,linux/arm64/v8"]
include:
- php_version: "7.4"
composer_version: "2"
latest_major: "true"
- php_version: "7.4"
composer_version: "1"
latest_major: "true"
- php_version: "8.3"
composer_version: "1"
latest_major: "true"
- php_version: "8.3"
composer_version: "2"
latest: "true"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta (base)
id: meta-base
uses: docker/metadata-action@v5
with:
images: |
clevyr/php
ghcr.io/clevyr/php
flavor: latest=false
tags: |
# {{major}}.{{minor}}-composer{{major}}-base
type=semver,pattern={{major}}.{{minor}},suffix=-composer${{ matrix.composer_version }}-base,value=${{ matrix.php_version }}.0
# {{major}}.{{minor}}-base
type=semver,enable=${{ matrix.composer_version == '2' }},pattern={{major}}.{{minor}},suffix=-base,value=${{ matrix.php_version }}.0
# {{major}}-base
type=semver,enable=${{ matrix.composer_version == '2' && (matrix.latest_major == 'true' || matrix.latest == 'true') }},pattern={{major}},suffix=-base,value=${{ matrix.php_version }}.0
- name: Docker meta (onbuild)
id: meta-onbuild
uses: docker/metadata-action@v5
with:
images: |
clevyr/php
ghcr.io/clevyr/php
flavor: latest=false
tags: |
# latest
type=raw,enable=${{ matrix.latest == 'true' }},value=latest
# {{major}}.{{minor}}-composer{{major}}-onbuild
type=semver,pattern={{major}}.{{minor}},suffix=-composer${{ matrix.composer_version }}-onbuild,value=${{ matrix.php_version }}.0
# {{major}}.{{minor}}-composer{{major}}
type=semver,pattern={{major}}.{{minor}},suffix=-composer${{ matrix.composer_version }},value=${{ matrix.php_version }}.0
# {{major}}.{{minor}}-onbuild
type=semver,enable=${{ matrix.composer_version == '2' }},pattern={{major}}.{{minor}},suffix=-onbuild,value=${{ matrix.php_version }}.0
# {{major}}.{{minor}}
type=semver,enable=${{ matrix.composer_version == '2' }},pattern={{major}}.{{minor}},value=${{ matrix.php_version }}.0
# {{major}}-composer{{major}}
type=semver,enable=${{ (matrix.latest_major == 'true' || matrix.latest == 'true') }},pattern={{major}},suffix=-composer${{ matrix.composer_version }},value=${{ matrix.php_version }}.0
# {{major}}-onbuild
type=semver,enable=${{ matrix.composer_version == '2' && (matrix.latest_major == 'true' || matrix.latest == 'true') }},pattern={{major}},suffix=-onbuild,value=${{ matrix.php_version }}.0
# {{major}}
type=semver,enable=${{ matrix.composer_version == '2' && (matrix.latest_major == 'true' || matrix.latest == 'true') }},pattern={{major}},value=${{ matrix.php_version }}.0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build
uses: docker/build-push-action@v6
with:
context: .
pull: true
load: true
tags: ${{ env.TEST_TAG }}
build-args: |
COMPOSER_VERSION=${{ matrix.composer_version }}
PHP_VERSION=${{ matrix.php_version }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test nginx config
run: docker run --rm -i "$TEST_TAG" nginx -t
- name: Test php-fpm config
run: docker run --rm -i "$TEST_TAG" php-fpm -tt
- name: Test commands exist
run: docker run --rm -i "$TEST_TAG" which composer install-php-extensions clevyr-build
- name: Build and Push (base)
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.ref == 'refs/heads/main' }}
platforms: ${{ matrix.platforms }}
tags: ${{ steps.meta-base.outputs.tags }}
labels: ${{ steps.meta-base.outputs.labels }}
build-args: |
COMPOSER_VERSION=${{ matrix.composer_version }}
PHP_VERSION=${{ matrix.php_version }}
target: base
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and Push (onbuild)
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.ref == 'refs/heads/main' }}
platforms: ${{ matrix.platforms }}
tags: ${{ steps.meta-onbuild.outputs.tags }}
labels: ${{ steps.meta-onbuild.outputs.labels }}
build-args: |
COMPOSER_VERSION=${{ matrix.composer_version }}
PHP_VERSION=${{ matrix.php_version }}
target: onbuild
cache-from: type=gha
cache-to: type=gha,mode=max