From 043fcdc1365933260c7c2c3362974143abfc6180 Mon Sep 17 00:00:00 2001 From: bunkerity Date: Wed, 9 Dec 2020 18:30:12 +0100 Subject: [PATCH] autoconf - automated build --- Dockerfile | 6 ++---- Dockerfile-amd64 | 6 ++---- Dockerfile-arm32v7 | 6 ++---- Dockerfile-arm64v8 | 6 ++---- Dockerfile-i386 | 6 ++---- autoconf/hooks/post_push | 12 ++++++++++++ autoconf/hooks/pre_build | 5 +++++ autoconf/utils.py | 2 +- examples/autoconf-php/docker-compose.yml | 2 +- .../autoconf-reverse-proxy/docker-compose.yml | 2 +- hooks/post_push | 16 +++++++--------- 11 files changed, 37 insertions(+), 32 deletions(-) create mode 100644 autoconf/hooks/post_push create mode 100644 autoconf/hooks/pre_build diff --git a/Dockerfile b/Dockerfile index 1da35ad..f452de1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,11 +18,9 @@ COPY fail2ban/ /opt/fail2ban COPY logs/ /opt/logs COPY lua/ /opt/lua COPY crowdsec/ /opt/crowdsec -COPY autoconf/ /opt/autoconf -RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd go jq mariadb-connector-c bash brotli py3-pip && \ - pip3 install docker && \ - chmod +x /opt/entrypoint/* /opt/scripts/* /opt/autoconf/autoconf.py && \ +RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd go jq mariadb-connector-c bash brotli && \ + chmod +x /opt/entrypoint/* /opt/scripts/* && \ mkdir /opt/entrypoint.d && \ rm -f /var/log/nginx/* && \ chown root:nginx /var/log/nginx && \ diff --git a/Dockerfile-amd64 b/Dockerfile-amd64 index 32d88f2..6807788 100644 --- a/Dockerfile-amd64 +++ b/Dockerfile-amd64 @@ -18,11 +18,9 @@ COPY fail2ban/ /opt/fail2ban COPY logs/ /opt/logs COPY lua/ /opt/lua COPY crowdsec/ /opt/crowdsec -COPY autoconf/ /opt/autoconf -RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd go jq mariadb-connector-c bash brotli py3-pip && \ - pip3 install docker && \ - chmod +x /opt/entrypoint/* /opt/scripts/* /opt/autoconf/autoconf.py && \ +RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd go jq mariadb-connector-c bash brotli && \ + chmod +x /opt/entrypoint/* /opt/scripts/* && \ mkdir /opt/entrypoint.d && \ rm -f /var/log/nginx/* && \ chown root:nginx /var/log/nginx && \ diff --git a/Dockerfile-arm32v7 b/Dockerfile-arm32v7 index f239b12..fae988a 100644 --- a/Dockerfile-arm32v7 +++ b/Dockerfile-arm32v7 @@ -25,11 +25,9 @@ COPY fail2ban/ /opt/fail2ban COPY logs/ /opt/logs COPY lua/ /opt/lua COPY crowdsec/ /opt/crowdsec -COPY autoconf/ /opt/autoconf -RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd go jq mariadb-connector-c bash brotli py3-pip && \ - pip3 install docker && \ - chmod +x /opt/entrypoint/* /opt/scripts/* /opt/autoconf/autoconf.py && \ +RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd go jq mariadb-connector-c bash brotli && \ + chmod +x /opt/entrypoint/* /opt/scripts/* && \ mkdir /opt/entrypoint.d && \ rm -f /var/log/nginx/* && \ chown root:nginx /var/log/nginx && \ diff --git a/Dockerfile-arm64v8 b/Dockerfile-arm64v8 index 114ff7e..2c9a757 100644 --- a/Dockerfile-arm64v8 +++ b/Dockerfile-arm64v8 @@ -25,11 +25,9 @@ COPY fail2ban/ /opt/fail2ban COPY logs/ /opt/logs COPY lua/ /opt/lua COPY crowdsec/ /opt/crowdsec -COPY autoconf/ /opt/autoconf -RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd go jq mariadb-connector-c bash brotli py3-pip && \ - pip3 install docker && \ - chmod +x /opt/entrypoint/* /opt/scripts/* /opt/autoconf/autoconf.py && \ +RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd go jq mariadb-connector-c bash brotli && \ + chmod +x /opt/entrypoint/* /opt/scripts/* && \ mkdir /opt/entrypoint.d && \ rm -f /var/log/nginx/* && \ chown root:nginx /var/log/nginx && \ diff --git a/Dockerfile-i386 b/Dockerfile-i386 index b0207c7..b3f24fd 100644 --- a/Dockerfile-i386 +++ b/Dockerfile-i386 @@ -18,11 +18,9 @@ COPY fail2ban/ /opt/fail2ban COPY logs/ /opt/logs COPY lua/ /opt/lua COPY crowdsec/ /opt/crowdsec -COPY autoconf/ /opt/autoconf -RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd go jq mariadb-connector-c bash brotli py3-pip && \ - pip3 install docker && \ - chmod +x /opt/entrypoint/* /opt/scripts/* /opt/autoconf/autoconf.py && \ +RUN apk --no-cache add certbot libstdc++ libmaxminddb geoip pcre yajl fail2ban clamav apache2-utils rsyslog openssl lua libgd go jq mariadb-connector-c bash brotli && \ + chmod +x /opt/entrypoint/* /opt/scripts/* && \ mkdir /opt/entrypoint.d && \ rm -f /var/log/nginx/* && \ chown root:nginx /var/log/nginx && \ diff --git a/autoconf/hooks/post_push b/autoconf/hooks/post_push new file mode 100644 index 0000000..821682c --- /dev/null +++ b/autoconf/hooks/post_push @@ -0,0 +1,12 @@ +#!/bin/bash + +curl -Lo manifest-tool https://github.com/estesp/manifest-tool/releases/download/v1.0.3/manifest-tool-linux-amd64 +chmod +x manifest-tool + +VERSION=$(cat VERSION | tr -d '\n') +if [ "$SOURCE_BRANCH" = "dev" ] ; then + ./manifest-tool push from-args --ignore-missing --platforms linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8 --template bunkerity/bunkerized-nginx-autoconf:dev-ARCHVARIANT --target bunkerity/bunkerized-nginx-autoconf:dev +elif [ "$SOURCE_BRANCH" = "master" ] ; then + ./manifest-tool push from-args --ignore-missing --platforms linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8 --template bunkerity/bunkerized-nginx-autoconf:ARCHVARIANT --target bunkerity/bunkerized-nginx-autoconf:${VERSION} + ./manifest-tool push from-args --ignore-missing --platforms linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8 --template bunkerity/bunkerized-nginx-autoconf:ARCHVARIANT --target bunkerity/bunkerized-nginx-autoconf:latest +fi diff --git a/autoconf/hooks/pre_build b/autoconf/hooks/pre_build new file mode 100644 index 0000000..acf05f1 --- /dev/null +++ b/autoconf/hooks/pre_build @@ -0,0 +1,5 @@ +#!/bin/bash + +# Register qemu-*-static for all supported processors except the +# current one, but also remove all registered binfmt_misc before +docker run --rm --privileged multiarch/qemu-user-static:register --reset diff --git a/autoconf/utils.py b/autoconf/utils.py index 328b004..53232f2 100644 --- a/autoconf/utils.py +++ b/autoconf/utils.py @@ -3,7 +3,7 @@ import datetime def log(event) : - print("[" + str(datetime.datetime.now().replace(microsecond=0)) + "] AUTOCONF - " + event, flush=True) + print("[" + str(datetime.datetime.now().replace(microsecond=0)) + "] " + event, flush=True) def replace_in_file(file, old_str, new_str) : with open(file) as f : diff --git a/examples/autoconf-php/docker-compose.yml b/examples/autoconf-php/docker-compose.yml index 38c0014..a75fde9 100644 --- a/examples/autoconf-php/docker-compose.yml +++ b/examples/autoconf-php/docker-compose.yml @@ -25,7 +25,7 @@ services: - "bunkerized-nginx.AUTOCONF" myautoconf: - image: bunkerity/bunkerized-nginx:autoconf + image: bunkerity/bunkerized-nginx-autoconf restart: always volumes: - /var/run/docker.sock:/var/run/docker.sock:ro diff --git a/examples/autoconf-reverse-proxy/docker-compose.yml b/examples/autoconf-reverse-proxy/docker-compose.yml index daaa53b..b0e4086 100644 --- a/examples/autoconf-reverse-proxy/docker-compose.yml +++ b/examples/autoconf-reverse-proxy/docker-compose.yml @@ -23,7 +23,7 @@ services: - USE_REVERSE_PROXY=yes myautoconf: - image: bunkerity/bunkerized-nginx:autoconf + image: bunkerity/bunkerized-nginx-autoconf restart: always volumes: - /var/run/docker.sock:/var/run/docker.sock:ro diff --git a/hooks/post_push b/hooks/post_push index 4cf5620..4c8845a 100644 --- a/hooks/post_push +++ b/hooks/post_push @@ -3,12 +3,10 @@ curl -Lo manifest-tool https://github.com/estesp/manifest-tool/releases/download/v1.0.3/manifest-tool-linux-amd64 chmod +x manifest-tool -echo "$DOCKER_REPO" - -#VERSION=$(cat VERSION | tr -d '\n') -#if [ "$SOURCE_BRANCH" = "dev" ] ; then -# ./manifest-tool push from-args --ignore-missing --platforms linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8 --template bunkerity/bunkerized-nginx:dev-ARCHVARIANT --target bunkerity/bunkerized-nginx:dev -#elif [ "$SOURCE_BRANCH" = "master" ] ; then -# ./manifest-tool push from-args --ignore-missing --platforms linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8 --template bunkerity/bunkerized-nginx:ARCHVARIANT --target bunkerity/bunkerized-nginx:${VERSION} -# ./manifest-tool push from-args --ignore-missing --platforms linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8 --template bunkerity/bunkerized-nginx:ARCHVARIANT --target bunkerity/bunkerized-nginx:latest -#fi +VERSION=$(cat VERSION | tr -d '\n') +if [ "$SOURCE_BRANCH" = "dev" ] ; then + ./manifest-tool push from-args --ignore-missing --platforms linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8 --template bunkerity/bunkerized-nginx:dev-ARCHVARIANT --target bunkerity/bunkerized-nginx:dev +elif [ "$SOURCE_BRANCH" = "master" ] ; then + ./manifest-tool push from-args --ignore-missing --platforms linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8 --template bunkerity/bunkerized-nginx:ARCHVARIANT --target bunkerity/bunkerized-nginx:${VERSION} + ./manifest-tool push from-args --ignore-missing --platforms linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8 --template bunkerity/bunkerized-nginx:ARCHVARIANT --target bunkerity/bunkerized-nginx:latest +fi