Skip to content

Fix image build

Fix image build #130

name: "Build Container Image"
on:
push:
branches:
- main
tags:
- "*"
paths-ignore:
- "**/*.md"
- "LICENSE"
pull_request:
workflow_dispatch:
env:
HAPROXY_IMAGES: >
haproxy:2.2-alpine
haproxy:2.4-alpine
haproxy:2.5-alpine
haproxy:2.6-alpine
haproxy:2.7-alpine
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Run e2e tests against the example
shell: bash
run: >
for image in $HAPROXY_IMAGES; do
echo "Running e2e with Haproxy image $image"
HAPROXY_IMAGE=$image docker compose -f docker-compose.e2e.yaml up --abort-on-container-exit tests
done
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata - Main
id: meta-main
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=snapshot,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=branch
type=ref,event=pr
- name: Image - Main
uses: docker/build-push-action@v3
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
file: Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-main.outputs.tags }}
labels: ${{ steps.meta-main.outputs.labels }}
- name: Docker metadata - CRS4
id: meta-crs4
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
flavor: |
suffix=-crs4,onlatest=true
tags: |
type=raw,value=snapshot,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=branch
type=ref,event=pr
- name: Image - CRS4
uses: docker/build-push-action@v3
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
file: Dockerfile
push: ${{ github.event_name != 'pull_request' }}
target: coreruleset
build-args: |
CORERULESET_VERSION=v4.0.0-rc1
tags: ${{ steps.meta-crs4.outputs.tags }}
labels: ${{ steps.meta-crs4.outputs.labels }}