-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): use unique tags when pushing to hub
- tags are based on build date using YYYYMMDDHHMM Signed-off-by: Felipe Zipitria <[email protected]>
- Loading branch information
Showing
8 changed files
with
123 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,49 +3,61 @@ on: | |
push: | ||
branches: | ||
- master | ||
schedule: | ||
- cron: "0 12 * * TUE" # Run every Tuesday (base run on Monday) | ||
repository_dispatch: | ||
types: [base-container-updated] | ||
|
||
env: | ||
REPO: "owasp/modsecurity-crs" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
crs-version: | ||
- "3.3.2" | ||
image: | ||
- apache | ||
- nginx | ||
variant: | ||
- "" | ||
- "-alpine" | ||
crs_version: ["3.3.4"] | ||
image: [apache, nginx] | ||
variant: ["", "-alpine"] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
|
||
# https://github.com/docker/setup-qemu-action | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
# https://github.com/docker/setup-buildx-action | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
driver-opts: image=moby/buildkit:master | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.dockerhub_user }} | ||
password: ${{ secrets.dockerhub_token }} | ||
|
||
- name: Build and push ${{ matrix.crs-version }}-${{ matrix.image }}${{ matrix.variant }} | ||
uses: docker/[email protected] | ||
- name: Docker meta ${{ matrix.crs_version }}-${{ matrix.image }}${{ matrix.variant }} | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
${{ env.REPO }} | ||
flavor: | | ||
latest=false | ||
tags: | | ||
type=raw,value=${{ matrix.image }}${{ matrix.variant }} | ||
type=semver,pattern={{major}},value=v${{ matrix.crs_version }},suffix=${{ matrix.image }}${{ matrix.variant }}-{{date 'YYYYMMDDHHMM'}} | ||
type=semver,pattern={{major}}.{{minor}},value=v${{ matrix.crs_version }},suffix=${{ matrix.image }}${{ matrix.variant }}-{{date 'YYYYMMDDHHMM'}} | ||
type=semver,pattern={{version}},value=v${{ matrix.crs_version }},suffix=${{ matrix.image }}${{ matrix.variant }}-{{date 'YYYYMMDDHHMM'}} | ||
- name: Build and push ${{ matrix.crs_version }}-${{ matrix.image }}${{ matrix.variant }} | ||
uses: docker/[email protected] | ||
with: | ||
targets: ${{ matrix.image }}${{ matrix.variant }} | ||
files: docker-bake.hcl | ||
files: | | ||
./docker-bake.hcl | ||
${{ steps.meta.outputs.bake-file }} | ||
push: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,53 +5,68 @@ on: | |
branches: | ||
- master | ||
- develop | ||
|
||
env: | ||
REPO: "owasp/modsecurity-crs" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
crs-version: | ||
- "3.3.2" | ||
image: | ||
- apache | ||
- nginx | ||
variant: | ||
- "" | ||
- "-alpine" | ||
platform: | ||
- linux/amd64 | ||
crs_version: ["3.3.4"] | ||
image: [apache, nginx] | ||
variant: ["", "-alpine"] | ||
platform: [linux/amd64] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
|
||
# https://github.com/docker/setup-qemu-action | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
# https://github.com/docker/setup-buildx-action | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
driver-opts: image=moby/buildkit:master | ||
|
||
- name: Build ${{ matrix.crs-version }}-${{ matrix.image }}${{ matrix.variant }} | ||
uses: docker/[email protected] | ||
- name: Docker meta ${{ matrix.crs_version }}-${{ matrix.image }}${{ matrix.variant }} | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
${{ env.REPO }} | ||
flavor: | | ||
latest=false | ||
tags: | | ||
type=raw,value=${{ matrix.image }}${{ matrix.variant }} | ||
type=semver,pattern={{major}},value=v${{ matrix.crs_version }},suffix=${{ matrix.image }}${{ matrix.variant }}-{{date 'YYYYMMDDHHMM'}} | ||
type=semver,pattern={{major}}.{{minor}},value=v${{ matrix.crs_version }},suffix=${{ matrix.image }}${{ matrix.variant }}-{{date 'YYYYMMDDHHMM'}} | ||
type=semver,pattern={{version}},value=v${{ matrix.crs_version }},suffix=${{ matrix.image }}${{ matrix.variant }}-{{date 'YYYYMMDDHHMM'}} | ||
- name: Build ${{ matrix.crs_version }}-${{ matrix.image }}${{ matrix.variant }} | ||
uses: docker/[email protected] | ||
with: | ||
files: docker-bake.hcl | ||
targets: ${{ matrix.image }}${{ matrix.variant }} | ||
files: | | ||
./docker-bake.hcl | ||
${{ steps.meta.outputs.bake-file }} | ||
set: | | ||
"${{ matrix.image }}${{ matrix.variant }}.tags=${{ matrix.crs-version }}-${{ matrix.image }}${{ matrix.variant }}-test" | ||
"${{ matrix.image }}${{ matrix.variant }}.platform=${{ matrix.platform }}" | ||
load: true | ||
push: false | ||
|
||
- name: Run ${{ matrix.image }}${{ matrix.variant }} | ||
- name: Run ${{ matrix.crs_version }}-${{ matrix.image }}${{ matrix.variant }} | ||
run: | | ||
docker run -d --name ${{ matrix.crs-version }}-${{ matrix.image }}${{ matrix.variant }}-test ${{ matrix.crs-version }}-${{ matrix.image }}${{ matrix.variant }}-test | ||
docker logs ${{ matrix.crs-version }}-${{ matrix.image }}${{ matrix.variant }}-test | ||
TAG=$(docker image inspect -f '{{ json .RepoTags }}' ${{ env.REPO }}:${{ matrix.image }}${{ matrix.variant }} | jq -r '.[0]') | ||
echo "Starting container with TAG=$TAG" | ||
docker run --pull "never" -d --name ${{ matrix.crs_version }}-${{ matrix.image }}${{ matrix.variant }}-test "$TAG" | ||
docker logs ${{ matrix.crs_version }}-${{ matrix.image }}${{ matrix.variant }}-test | ||
- name: Verify ${{ matrix.crs-version }}-${{ matrix.image }}${{ matrix.variant }} | ||
- name: Verify ${{ matrix.crs_version }}-${{ matrix.image }}${{ matrix.variant }} | ||
run: | | ||
[ $(docker inspect ${{ matrix.crs-version }}-${{ matrix.image }}${{ matrix.variant }}-test --format='{{.State.Running}}') = 'true' ] | ||
[ $(docker inspect ${{ matrix.crs_version }}-${{ matrix.image }}${{ matrix.variant }}-test --format='{{.State.Running}}') = 'true' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM owasp/modsecurity:apache as release | ||
FROM owasp/modsecurity:2.9.6-202209170109 as release | ||
|
||
ARG RELEASE | ||
|
||
|
@@ -23,7 +23,7 @@ RUN set -eux; \ | |
sed -i -E 's/(Listen) [0-9]+/\1 ${PORT}/g' /usr/local/apache2/conf/httpd.conf; \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
FROM owasp/modsecurity:apache | ||
FROM owasp/modsecurity:2.9.6-202209170109 | ||
|
||
LABEL maintainer="Felipe Zipitria <[email protected]>" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM owasp/modsecurity:apache-alpine as release | ||
FROM owasp/modsecurity:2.9.6-alpine-202209170109 as release | ||
|
||
ARG RELEASE | ||
|
||
|
@@ -22,7 +22,7 @@ RUN set -eux; \ | |
ln -sv /opt/owasp-crs /etc/modsecurity.d/; \ | ||
sed -i -E 's/(Listen) [0-9]+/\1 ${PORT}/g' /usr/local/apache2/conf/httpd.conf | ||
|
||
FROM owasp/modsecurity:apache-alpine | ||
FROM owasp/modsecurity:2.9.6-alpine-202209170109 | ||
|
||
LABEL maintainer="Felipe Zipitria <[email protected]>" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM owasp/modsecurity:nginx as release | ||
FROM owasp/modsecurity:3.0.8-202209170109 as release | ||
|
||
ARG RELEASE | ||
|
||
|
@@ -18,7 +18,7 @@ RUN set -eux; \ | |
rm -f v${RELEASE}.tar.gz coreruleset-${RELEASE}.tar.gz.asc; \ | ||
mv -v /opt/owasp-crs/crs-setup.conf.example /opt/owasp-crs/crs-setup.conf | ||
|
||
FROM owasp/modsecurity:nginx | ||
FROM owasp/modsecurity:3.0.8-202209170109 | ||
|
||
LABEL maintainer="Felipe Zipitria <[email protected]>" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM owasp/modsecurity:nginx-alpine as release | ||
FROM owasp/modsecurity:3.0.8-alpine-202209170109 as release | ||
|
||
ARG RELEASE | ||
|
||
|
@@ -18,7 +18,7 @@ RUN set -eux; \ | |
mv -v /opt/owasp-crs/crs-setup.conf.example /opt/owasp-crs/crs-setup.conf; \ | ||
ln -sv /opt/owasp-crs /etc/modsecurity.d/ | ||
|
||
FROM owasp/modsecurity:nginx-alpine | ||
FROM owasp/modsecurity:3.0.8-alpine-202209170109 | ||
|
||
LABEL maintainer="Felipe Zipitria <[email protected]>" | ||
|
||
|