Skip to content

Commit

Permalink
feat: add nginx and nginx-otel build jobs to CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Oct 14, 2024
1 parent 01e11c3 commit 97fb358
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 2 deletions.
75 changes: 73 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,81 @@ jobs:
push: true
provenance: false

nginx:
name: Build Nginx with ${{ matrix.php }}
runs-on: ubuntu-latest
needs: [generate-matrix, fpm]
strategy: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login into Docker Hub
if: github.ref == 'refs/heads/main'
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin

- name: Login into Github Docker Registery
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

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

- name: Build and Push
uses: docker/build-push-action@v6
with:
tags: |
${{ matrix.nginx-tags }}
context: nginx
cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.php }}-nginx
cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.php }}-nginx,mode=max
platforms: linux/amd64,linux/arm64
build-args: |
FPM_IMAGE=${{ matrix.fpm-image }}
push: true
provenance: false

nginx-otel:
name: Build Nginx with ${{ matrix.php }} with OpenTelemetry
runs-on: ubuntu-latest
needs: [generate-matrix, fpm]
strategy: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login into Docker Hub
if: github.ref == 'refs/heads/main'
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin

- name: Login into Github Docker Registery
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

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

- name: Build and Push
uses: docker/build-push-action@v6
with:
tags: |
${{ matrix.nginx-tags-otel }}
context: nginx
cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.php }}-nginx-otel
cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.php }}-nginx-otel,mode=max
platforms: linux/amd64,linux/arm64
build-args: |
FPM_IMAGE=${{ matrix.fpm-image }}-otel
push: true
provenance: false

check:
name: Test Image
name: Test Image with Webserver ${{ matrix.webserver }}
runs-on: ubuntu-latest
needs: [caddy]
strategy:
matrix:
webserver:
- caddy
- nginx
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -188,7 +259,7 @@ jobs:

- name: Build PR
if: github.ref != 'refs/heads/main'
run: docker compose build --build-arg BASE_IMAGE=ghcr.io/shopware/docker-base-ci-test:${{ github.run_id }}-8.3-caddy
run: docker compose build --build-arg BASE_IMAGE=ghcr.io/shopware/docker-base-ci-test:${{ github.run_id }}-8.3-${{ matrix.webserver}}
env:
DOCKER_BUILDKIT: 0

Expand Down
22 changes: 22 additions & 0 deletions matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ function get_digest_of_image(string $imageName, string $tag): string {
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $patchVersion['version'] . '-caddy-otel',
];

$nginxImages = [
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $supportedVersion . '-nginx',
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $patchVersion['version'] . '-nginx',
];

$nginxImagesOtel = [
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $supportedVersion . '-nginx-otel',
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $patchVersion['version'] . '-nginx-otel',
];

$fpmImages = [
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $supportedVersion . '-fpm',
'ghcr.io/shopware/docker-base' . $imageSuffix . ':' . $imageTagPrefix . $patchVersion['version'] . '-fpm'
Expand All @@ -113,6 +123,16 @@ function get_digest_of_image(string $imageName, string $tag): string {
'shopware/docker-base:' . $imageTagPrefix . $patchVersion['version'] . '-caddy-otel',
]);

$nginxImages = array_merge($nginxImages, [
'shopware/docker-base:' . $imageTagPrefix . $supportedVersion . '-nginx',
'shopware/docker-base:' . $imageTagPrefix . $patchVersion['version'] . '-nginx',
]);

$nginxImagesOtel = array_merge($nginxImagesOtel, [
'shopware/docker-base:' . $imageTagPrefix . $supportedVersion . '-nginx-otel',
'shopware/docker-base:' . $imageTagPrefix . $patchVersion['version'] . '-nginx-otel',
]);

$fpmImages = array_merge($fpmImages, [
'shopware/docker-base:' . $imageTagPrefix . $supportedVersion . '-fpm',
'shopware/docker-base:' . $imageTagPrefix . $patchVersion['version'] . '-fpm'
Expand All @@ -133,6 +153,8 @@ function get_digest_of_image(string $imageName, string $tag): string {
'fpm-tags-otel' => implode("\n", $fpmImagesOtel),
'caddy-tags' => implode("\n", $caddyImages),
'caddy-tags-otel' => implode("\n", $caddyImagesOtel),
'nginx-tags' => implode("\n", $nginxImages),
'nginx-tags-otel' => implode("\n", $nginxImagesOtel),
'scan-tag' => $caddyImages[0],
'scan-to' => 'ghcr.io/shopware/docker-base:'.$supportedVersion,
];
Expand Down

0 comments on commit 97fb358

Please sign in to comment.