From 3b3fc0c5b666d62060a3a0bea59e963fe39328dc Mon Sep 17 00:00:00 2001 From: cytopia Date: Sun, 27 Mar 2022 22:05:54 +0200 Subject: [PATCH] Add Alpine Docker flavour --- .github/workflows/action_branch.yml | 2 +- .github/workflows/action_pull_request.yml | 2 +- .github/workflows/action_schedule.yml | 2 +- .github/workflows/params.yml | 1 + Dockerfiles/Dockerfile.alpine | 174 ++++++++++++++++++ Dockerfile => Dockerfiles/Dockerfile.debian | 0 Dockerfiles/Dockerfile.latest | 1 + {data => Dockerfiles/data}/create-vhost.sh | 0 .../data}/docker-entrypoint.d/00-base-libs.sh | 0 .../data}/docker-entrypoint.d/01-uid-gid.sh | 0 .../data}/docker-entrypoint.d/02-timezone.sh | 0 .../docker-entrypoint.d/03-docker-logs.sh | 0 .../docker-entrypoint.d/04-php-fpm-compat.sh | 0 .../data}/docker-entrypoint.d/04-php-fpm.sh | 0 .../docker-entrypoint.d/05-main-vhost.sh | 0 .../docker-entrypoint.d/06-mass-vhost.sh | 0 .../data}/docker-entrypoint.d/07-vhost-gen.sh | 0 .../data}/docker-entrypoint.d/08-cert-gen.sh | 0 .../docker-entrypoint.d/09-fix-permissions.sh | 0 .../docker-entrypoint.d/10-supervisord.sh | 0 .../data}/docker-entrypoint.sh | 0 {data => Dockerfiles/data}/vhost-gen/main.yml | 0 {data => Dockerfiles/data}/vhost-gen/mass.yml | 0 Makefile | 15 +- README.md | 3 +- 25 files changed, 193 insertions(+), 7 deletions(-) create mode 100644 Dockerfiles/Dockerfile.alpine rename Dockerfile => Dockerfiles/Dockerfile.debian (100%) create mode 120000 Dockerfiles/Dockerfile.latest rename {data => Dockerfiles/data}/create-vhost.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/00-base-libs.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/01-uid-gid.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/02-timezone.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/03-docker-logs.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/04-php-fpm-compat.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/04-php-fpm.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/05-main-vhost.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/06-mass-vhost.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/07-vhost-gen.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/08-cert-gen.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/09-fix-permissions.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.d/10-supervisord.sh (100%) rename {data => Dockerfiles/data}/docker-entrypoint.sh (100%) rename {data => Dockerfiles/data}/vhost-gen/main.yml (100%) rename {data => Dockerfiles/data}/vhost-gen/mass.yml (100%) diff --git a/.github/workflows/action_branch.yml b/.github/workflows/action_branch.yml index 55d6950..3197415 100644 --- a/.github/workflows/action_branch.yml +++ b/.github/workflows/action_branch.yml @@ -22,7 +22,7 @@ jobs: # (2/2) Build docker: needs: [params] - uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master + uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master with: enabled: true can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }} diff --git a/.github/workflows/action_pull_request.yml b/.github/workflows/action_pull_request.yml index c80bf78..21b075b 100644 --- a/.github/workflows/action_pull_request.yml +++ b/.github/workflows/action_pull_request.yml @@ -24,7 +24,7 @@ jobs: # (2/2) Build docker: needs: [params] - uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master + uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master with: enabled: true can_deploy: false diff --git a/.github/workflows/action_schedule.yml b/.github/workflows/action_schedule.yml index 36d979a..c25dfa2 100644 --- a/.github/workflows/action_schedule.yml +++ b/.github/workflows/action_schedule.yml @@ -24,7 +24,7 @@ jobs: # (2/2) Build docker: needs: [params] - uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master + uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master with: enabled: true can_deploy: true diff --git a/.github/workflows/params.yml b/.github/workflows/params.yml index f5ff908..5acafdc 100644 --- a/.github/workflows/params.yml +++ b/.github/workflows/params.yml @@ -15,6 +15,7 @@ env: { "NAME": "Apache", "VERSION": ["2.4"], + "FLAVOUR": ["latest", "debian", "alpine"], "ARCH": ["linux/amd64", "linux/386", "linux/arm64", "linux/arm/v7", "linux/arm/v6"] } ] diff --git a/Dockerfiles/Dockerfile.alpine b/Dockerfiles/Dockerfile.alpine new file mode 100644 index 0000000..1abc2cc --- /dev/null +++ b/Dockerfiles/Dockerfile.alpine @@ -0,0 +1,174 @@ +FROM httpd:2.4-alpine +MAINTAINER "cytopia" + +LABEL \ + name="cytopia's apache 2.4 image" \ + image="devilbox/apache-2.4" \ + vendor="devilbox" \ + license="MIT" + + +### +### Build arguments +### +ARG VHOST_GEN_GIT_REF=1.0.3 +ARG WATCHERD_GIT_REF=v1.0.2 +ARG CERT_GEN_GIT_REF=0.7 + +ENV BUILD_DEPS \ + make \ + wget + +ENV RUN_DEPS \ + ca-certificates \ + bash \ + openssl \ + py3-yaml \ + shadow \ + supervisor + + +### +### Runtime arguments +### +ENV MY_USER=www-data +ENV MY_GROUP=www-data +ENV HTTPD_START="httpd-foreground" +ENV HTTPD_RELOAD="/usr/local/apache2/bin/httpd -k stop" + + +### +### Install required packages +### +RUN set -eux \ + && apk add --no-cache \ + ${BUILD_DEPS} \ + ${RUN_DEPS} \ + \ + # Install vhost-gen + && wget --no-check-certificate -O vhost-gen.tar.gz "https://github.com/devilbox/vhost-gen/archive/refs/tags/${VHOST_GEN_GIT_REF}.tar.gz" \ + && tar xvfz vhost-gen.tar.gz \ + && cd "vhost-gen-${VHOST_GEN_GIT_REF}" \ + && make install \ + && cd .. \ + && rm -rf vhost*gen* \ + \ + # Install cert-gen + && wget --no-check-certificate -O /usr/bin/ca-gen https://raw.githubusercontent.com/devilbox/cert-gen/${CERT_GEN_GIT_REF}/bin/ca-gen \ + && wget --no-check-certificate -O /usr/bin/cert-gen https://raw.githubusercontent.com/devilbox/cert-gen/${CERT_GEN_GIT_REF}/bin/cert-gen \ + && chmod +x /usr/bin/ca-gen \ + && chmod +x /usr/bin/cert-gen \ + \ + # Install watcherd + && wget --no-check-certificate -O /usr/bin/watcherd https://raw.githubusercontent.com/devilbox/watcherd/${WATCHERD_GIT_REF}/watcherd \ + && chmod +x /usr/bin/watcherd \ + \ + # Clean-up + && apk del \ + ${BUILD_DEPS} + + +### +### Configure Apache +### +RUN set -eux \ + && APACHE_VERSION="$( httpd -V | grep -Eo 'Apache/[.0-9]+' | awk -F'/' '{print $2}' )" \ + && ( \ + echo "ServerName localhost"; \ + \ + echo "LoadModule http2_module modules/mod_http2.so"; \ + echo "LoadModule proxy_module modules/mod_proxy.so"; \ + echo "LoadModule proxy_http_module modules/mod_proxy_http.so"; \ + echo "LoadModule proxy_http2_module modules/mod_proxy_http2.so"; \ + echo "LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so"; \ + echo "LoadModule rewrite_module modules/mod_rewrite.so"; \ + \ + echo "Include conf/extra/httpd-default.conf"; \ + echo "IncludeOptional /etc/httpd-custom.d/*.conf"; \ + echo "IncludeOptional /etc/httpd/conf.d/*.conf"; \ + echo "IncludeOptional /etc/httpd/vhost.d/*.conf"; \ + \ + echo "LoadModule ssl_module modules/mod_ssl.so"; \ + echo "LoadModule socache_shmcb_module modules/mod_socache_shmcb.so" ;\ + echo "Listen 443"; \ + echo "SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES"; \ + echo "SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES"; \ + echo "SSLHonorCipherOrder on"; \ + echo "SSLProtocol all -SSLv3"; \ + echo "SSLProxyProtocol all -SSLv3"; \ + echo "SSLPassPhraseDialog builtin"; \ + echo "SSLSessionCache \"shmcb:/usr/local/apache2/logs/ssl_scache(512000)\""; \ + echo "SSLSessionCacheTimeout 300"; \ + \ + echo ""; \ + echo " Header always set Via \"1.0 %{HOSTNAME}e (apache/${APACHE_VERSION})\""; \ + echo ""; \ + echo ""; \ + echo " Header always set Via \"1.1 %{HOSTNAME}e (apache/${APACHE_VERSION})\""; \ + echo ""; \ + echo ""; \ + echo " Header always set Via \"2.0 %{HOSTNAME}e (apache/${APACHE_VERSION})\""; \ + echo ""; \ + \ + echo "HTTPProtocolOptions unsafe"; \ + \ + # https://github.com/cytopia/devilbox/issues/862 + echo "Mutex sem"; \ + \ + ) >> /usr/local/apache2/conf/httpd.conf + + +### +### Create directories +### +RUN set -eux \ + && mkdir -p /etc/httpd-custom.d \ + && mkdir -p /etc/httpd/conf.d \ + && mkdir -p /etc/httpd/vhost.d \ + && mkdir -p /var/www/default/htdocs \ + && mkdir -p /shared/httpd \ + && chmod 0775 /shared/httpd \ + && chown ${MY_USER}:${MY_GROUP} /shared/httpd + + +### +### Symlink Python3 to Python +### +RUN set -eux \ + && ln -sf /usr/bin/python3 /usr/bin/python + + +### +### Copy files +### +COPY ./data/vhost-gen/main.yml /etc/vhost-gen/main.yml +COPY ./data/vhost-gen/mass.yml /etc/vhost-gen/mass.yml +COPY ./data/create-vhost.sh /usr/local/bin/create-vhost.sh +COPY ./data/docker-entrypoint.d /docker-entrypoint.d +COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh + + +### +### Ports +### +EXPOSE 80 +EXPOSE 443 + + +### +### Volumes +### +VOLUME /shared/httpd +VOLUME /ca + + +### +### Signals +### +STOPSIGNAL SIGTERM + + +### +### Entrypoint +### +ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/Dockerfile b/Dockerfiles/Dockerfile.debian similarity index 100% rename from Dockerfile rename to Dockerfiles/Dockerfile.debian diff --git a/Dockerfiles/Dockerfile.latest b/Dockerfiles/Dockerfile.latest new file mode 120000 index 0000000..d537b9a --- /dev/null +++ b/Dockerfiles/Dockerfile.latest @@ -0,0 +1 @@ +Dockerfile.debian \ No newline at end of file diff --git a/data/create-vhost.sh b/Dockerfiles/data/create-vhost.sh similarity index 100% rename from data/create-vhost.sh rename to Dockerfiles/data/create-vhost.sh diff --git a/data/docker-entrypoint.d/00-base-libs.sh b/Dockerfiles/data/docker-entrypoint.d/00-base-libs.sh similarity index 100% rename from data/docker-entrypoint.d/00-base-libs.sh rename to Dockerfiles/data/docker-entrypoint.d/00-base-libs.sh diff --git a/data/docker-entrypoint.d/01-uid-gid.sh b/Dockerfiles/data/docker-entrypoint.d/01-uid-gid.sh similarity index 100% rename from data/docker-entrypoint.d/01-uid-gid.sh rename to Dockerfiles/data/docker-entrypoint.d/01-uid-gid.sh diff --git a/data/docker-entrypoint.d/02-timezone.sh b/Dockerfiles/data/docker-entrypoint.d/02-timezone.sh similarity index 100% rename from data/docker-entrypoint.d/02-timezone.sh rename to Dockerfiles/data/docker-entrypoint.d/02-timezone.sh diff --git a/data/docker-entrypoint.d/03-docker-logs.sh b/Dockerfiles/data/docker-entrypoint.d/03-docker-logs.sh similarity index 100% rename from data/docker-entrypoint.d/03-docker-logs.sh rename to Dockerfiles/data/docker-entrypoint.d/03-docker-logs.sh diff --git a/data/docker-entrypoint.d/04-php-fpm-compat.sh b/Dockerfiles/data/docker-entrypoint.d/04-php-fpm-compat.sh similarity index 100% rename from data/docker-entrypoint.d/04-php-fpm-compat.sh rename to Dockerfiles/data/docker-entrypoint.d/04-php-fpm-compat.sh diff --git a/data/docker-entrypoint.d/04-php-fpm.sh b/Dockerfiles/data/docker-entrypoint.d/04-php-fpm.sh similarity index 100% rename from data/docker-entrypoint.d/04-php-fpm.sh rename to Dockerfiles/data/docker-entrypoint.d/04-php-fpm.sh diff --git a/data/docker-entrypoint.d/05-main-vhost.sh b/Dockerfiles/data/docker-entrypoint.d/05-main-vhost.sh similarity index 100% rename from data/docker-entrypoint.d/05-main-vhost.sh rename to Dockerfiles/data/docker-entrypoint.d/05-main-vhost.sh diff --git a/data/docker-entrypoint.d/06-mass-vhost.sh b/Dockerfiles/data/docker-entrypoint.d/06-mass-vhost.sh similarity index 100% rename from data/docker-entrypoint.d/06-mass-vhost.sh rename to Dockerfiles/data/docker-entrypoint.d/06-mass-vhost.sh diff --git a/data/docker-entrypoint.d/07-vhost-gen.sh b/Dockerfiles/data/docker-entrypoint.d/07-vhost-gen.sh similarity index 100% rename from data/docker-entrypoint.d/07-vhost-gen.sh rename to Dockerfiles/data/docker-entrypoint.d/07-vhost-gen.sh diff --git a/data/docker-entrypoint.d/08-cert-gen.sh b/Dockerfiles/data/docker-entrypoint.d/08-cert-gen.sh similarity index 100% rename from data/docker-entrypoint.d/08-cert-gen.sh rename to Dockerfiles/data/docker-entrypoint.d/08-cert-gen.sh diff --git a/data/docker-entrypoint.d/09-fix-permissions.sh b/Dockerfiles/data/docker-entrypoint.d/09-fix-permissions.sh similarity index 100% rename from data/docker-entrypoint.d/09-fix-permissions.sh rename to Dockerfiles/data/docker-entrypoint.d/09-fix-permissions.sh diff --git a/data/docker-entrypoint.d/10-supervisord.sh b/Dockerfiles/data/docker-entrypoint.d/10-supervisord.sh similarity index 100% rename from data/docker-entrypoint.d/10-supervisord.sh rename to Dockerfiles/data/docker-entrypoint.d/10-supervisord.sh diff --git a/data/docker-entrypoint.sh b/Dockerfiles/data/docker-entrypoint.sh similarity index 100% rename from data/docker-entrypoint.sh rename to Dockerfiles/data/docker-entrypoint.sh diff --git a/data/vhost-gen/main.yml b/Dockerfiles/data/vhost-gen/main.yml similarity index 100% rename from data/vhost-gen/main.yml rename to Dockerfiles/data/vhost-gen/main.yml diff --git a/data/vhost-gen/mass.yml b/Dockerfiles/data/vhost-gen/mass.yml similarity index 100% rename from data/vhost-gen/mass.yml rename to Dockerfiles/data/vhost-gen/mass.yml diff --git a/Makefile b/Makefile index 5289b70..7ac7f3e 100644 --- a/Makefile +++ b/Makefile @@ -27,9 +27,18 @@ TAG = latest NAME = Apache VERSION = 2.4 IMAGE = devilbox/apache-$(VERSION) -DIR = . -FILE = Dockerfile -DOCKER_TAG = $(TAG) +FLAVOUR = latest +DIR = Dockerfiles +FILE = Dockerfile.$(FLAVOUR) +ifeq ($(strip $(FLAVOUR)),latest) + DOCKER_TAG = $(TAG) +else + ifeq ($(strip $(TAG)),latest) + DOCKER_TAG = $(FLAVOUR) + else + DOCKER_TAG = $(FLAVOUR)-$(TAG) + endif +endif ARCH = linux/amd64 diff --git a/README.md b/README.md index cae85dd..df06c08 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ **[devilbox/docker-apache-2.4](https://github.com/devilbox/docker-apache-2.4)** -**Available Architectures:** `amd64`, `arm64`, `386`, `arm/v7`, `arm/v6` +* **Available Architectures:** `amd64`, `arm64`, `386`, `arm/v7`, `arm/v6` +* **Available Docker tags:** `latest`, `alpine`, `debian` This image is based on the official **[Apache 2.4](https://hub.docker.com/_/httpd)** Docker image and extends it with the ability to have **virtual hosts created automatically**, as well as **adding SSL certificates** when creating new directories. For that to work, it integrates two tools that will take care about the whole process: **[watcherd](https://github.com/devilbox/watcherd)** and **[vhost-gen](https://github.com/devilbox/vhost-gen)**.