-
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): change build to dockerx bake
Signed-off-by: Felipe Zipitria <[email protected]>
- Loading branch information
Showing
11 changed files
with
318 additions
and
116 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 |
---|---|---|
|
@@ -2,34 +2,48 @@ name: Build images for Docker Hub | |
on: | ||
push: | ||
branches: | ||
- master | ||
- master | ||
schedule: | ||
- cron: '0 12 * * MON' # Run every Monday | ||
- cron: "0 12 * * TUE" # Run every Tuesday (base run on Monday) | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
version: ['v3.3.2'] | ||
server: ['apache', 'nginx'] | ||
crs-version: | ||
- "3.3.2" | ||
image: | ||
- apache | ||
- nginx | ||
variant: | ||
- "" | ||
- "-alpine" | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Log in to Docker Hub | ||
run: docker login | ||
-u "${{ secrets.dockerhub_user }}" | ||
-p "${{ secrets.dockerhub_token }}" | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Build ${{ matrix.version }}-${{ matrix.server }} | ||
run: make VERSIONS=${{ matrix.version }} SERVERS=${{ matrix.server }} | ||
# https://github.com/docker/setup-qemu-action | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
# As we build multiple versions now, we need one to be the default | ||
- name: Set default tag for ${{ matrix.version }}-${{ matrix.server }} | ||
run: docker tag owasp/modsecurity-crs:${{ matrix.version }}-${{ matrix.server }} | ||
owasp/modsecurity-crs:${{ matrix.server }} | ||
# https://github.com/docker/setup-buildx-action | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
with: | ||
driver-opts: image=moby/buildkit:master | ||
|
||
- name: Push ${{ matrix.version }}-${{ matrix.server }} | ||
run: docker push --all-tags owasp/modsecurity-crs | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.dockerhub_user }} | ||
password: ${{ secrets.dockerhub_token }} | ||
|
||
- 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 | ||
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 |
---|---|---|
@@ -1,30 +1,56 @@ | ||
--- | ||
name: Verify Images | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
- master | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
# Remember to match these with the buildimage.yml action | ||
matrix: | ||
version: ['v3.3.2'] | ||
server: ['apache', 'nginx'] | ||
crs-version: | ||
- "3.3.2" | ||
image: | ||
- apache | ||
- nginx | ||
variant: | ||
- "" | ||
- "-alpine" | ||
platform: | ||
- linux/amd64 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Build ${{ matrix.version }}-${{ matrix.server }} | ||
run: make VERSIONS=${{ matrix.version }} SERVERS=${{ matrix.server }} TAG=test | ||
# https://github.com/docker/setup-qemu-action | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Run ${{ matrix.version }}-${{ matrix.server }} | ||
run: | | ||
docker run -d --name ${{ matrix.version }}-${{ matrix.server }} test:${{ matrix.version }}-${{ matrix.server }} | ||
docker logs --details ${{ matrix.version }}-${{ matrix.server }} | ||
# https://github.com/docker/setup-buildx-action | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
with: | ||
driver-opts: image=moby/buildkit:master | ||
|
||
- name: Verify ${{ matrix.version }}-${{ matrix.server }} | ||
run: | | ||
docker inspect ${{ matrix.version }}-${{ matrix.server }} | ||
[ $(docker inspect ${{ matrix.version }}-${{ matrix.server }} --format='{{.State.Running}}') = 'true' ] | ||
- name: Build ${{ matrix.crs-version }}-${{ matrix.image }}${{ matrix.variant }} | ||
uses: docker/[email protected] | ||
with: | ||
files: docker-bake.hcl | ||
targets: ${{ matrix.image }}${{ matrix.variant }} | ||
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 }} | ||
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 | ||
- name: Verify ${{ matrix.crs-version }}-${{ matrix.image }}${{ matrix.variant }} | ||
run: | | ||
[ $(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,8 +1,8 @@ | ||
FROM owasp/modsecurity:2 | ||
FROM owasp/modsecurity:apache | ||
|
||
LABEL maintainer="Chaim Sanders <[email protected]>" | ||
LABEL maintainer="Felipe Zipitria <[email protected]>" | ||
|
||
ARG RELEASE=%%RELEASE%% | ||
ARG RELEASE | ||
|
||
ENV PARANOIA=1 \ | ||
ANOMALY_INBOUND=5 \ | ||
|
@@ -31,22 +31,20 @@ COPY src/opt/modsecurity/activate-rules.sh /opt/modsecurity/ | |
COPY apache/conf/extra/*.conf /usr/local/apache2/conf/extra/ | ||
COPY apache/docker-entrypoint.sh / | ||
|
||
# Change default shell to bash | ||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
# hadolint ignore=DL3008,SC2016 | ||
RUN apt-get update \ | ||
&& apt-get -y install --no-install-recommends \ | ||
ca-certificates \ | ||
curl \ | ||
iproute2 \ | ||
&& mkdir /opt/owasp-crs \ | ||
&& curl -SL https://github.com/coreruleset/coreruleset/archive/${RELEASE}.tar.gz \ | ||
| tar -zxf - --strip-components=1 -C /opt/owasp-crs \ | ||
&& mv -v /opt/owasp-crs/crs-setup.conf.example /opt/owasp-crs/crs-setup.conf \ | ||
&& ln -sv /opt/owasp-crs /etc/modsecurity.d/ \ | ||
&& sed -i -E 's/(Listen) [0-9]+/\1 ${PORT}/g' /usr/local/apache2/conf/httpd.conf \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
RUN set -eux; \ | ||
apt-get update; \ | ||
apt-get -y install --no-install-recommends \ | ||
ca-certificates \ | ||
curl \ | ||
iproute2; \ | ||
mkdir /opt/owasp-crs; \ | ||
curl -SL https://github.com/coreruleset/coreruleset/archive/v${RELEASE}.tar.gz | \ | ||
tar -zxf - --strip-components=1 -C /opt/owasp-crs; \ | ||
mv -v /opt/owasp-crs/crs-setup.conf.example /opt/owasp-crs/crs-setup.conf; \ | ||
ln -sv /opt/owasp-crs /etc/modsecurity.d/; \ | ||
sed -i -E 's/(Listen) [0-9]+/\1 ${PORT}/g' /usr/local/apache2/conf/httpd.conf; \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
CMD ["apachectl", "-D", "FOREGROUND"] |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
FROM owasp/modsecurity:apache-alpine | ||
|
||
LABEL maintainer="Felipe Zipitria <[email protected]>" | ||
|
||
ARG RELEASE | ||
|
||
ENV PARANOIA=1 \ | ||
ANOMALY_INBOUND=5 \ | ||
ANOMALY_OUTBOUND=4 \ | ||
APACHE_TIMEOUT=60 \ | ||
LOGLEVEL=warn \ | ||
ERRORLOG='/proc/self/fd/2' \ | ||
USER=daemon \ | ||
GROUP=daemon \ | ||
SERVERADMIN=root@localhost \ | ||
SERVERNAME=localhost \ | ||
PORT=80 \ | ||
MODSEC_DEFAULT_PHASE1_ACTION="phase:1,pass,log,tag:'\${MODSEC_TAG}'" \ | ||
MODSEC_DEFAULT_PHASE2_ACTION="phase:2,pass,log,tag:'\${MODSEC_TAG}'" \ | ||
MODSEC_RULE_ENGINE=on \ | ||
MODSEC_REQ_BODY_ACCESS=on \ | ||
MODSEC_REQ_BODY_LIMIT=13107200 \ | ||
MODSEC_REQ_BODY_NOFILES_LIMIT=131072 \ | ||
MODSEC_RESP_BODY_ACCESS=on \ | ||
MODSEC_RESP_BODY_LIMIT=1048576 \ | ||
MODSEC_PCRE_MATCH_LIMIT=100000 \ | ||
MODSEC_PCRE_MATCH_LIMIT_RECURSION=100000 | ||
|
||
COPY src/etc/modsecurity.d/*.conf /etc/modsecurity.d/ | ||
COPY src/opt/modsecurity/activate-rules.sh /opt/modsecurity/ | ||
COPY apache/conf/extra/*.conf /usr/local/apache2/conf/extra/ | ||
COPY apache/docker-entrypoint.sh / | ||
|
||
# hadolint ignore=DL3008,SC2016 | ||
RUN set -eux; \ | ||
apk add --no-cache \ | ||
ca-certificates \ | ||
curl \ | ||
iproute2; \ | ||
mkdir /opt/owasp-crs; \ | ||
curl -SL https://github.com/coreruleset/coreruleset/archive/v${RELEASE}.tar.gz \ | ||
| tar -zxf - --strip-components=1 -C /opt/owasp-crs; \ | ||
mv -v /opt/owasp-crs/crs-setup.conf.example /opt/owasp-crs/crs-setup.conf; \ | ||
ln -sv /opt/owasp-crs /etc/modsecurity.d/; \ | ||
sed -i -E 's/(Listen) [0-9]+/\1 ${PORT}/g' /usr/local/apache2/conf/httpd.conf | ||
|
Oops, something went wrong.