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 b0741c3..cdf2782 100644 --- a/.github/workflows/params.yml +++ b/.github/workflows/params.yml @@ -15,6 +15,7 @@ env: { "NAME": "Nginx", "VERSION": ["mainline"], + "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..9f4b73e --- /dev/null +++ b/Dockerfiles/Dockerfile.alpine @@ -0,0 +1,128 @@ +FROM nginx:mainline-alpine +MAINTAINER "cytopia" + +LABEL \ + name="cytopia's nginx mainline image" \ + image="devilbox/nginx-mainline" \ + 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=nginx +ENV MY_GROUP=nginx +ENV HTTPD_START="/usr/sbin/nginx" +ENV HTTPD_RELOAD="nginx -s 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} + + +### +### Create directories +### +# /docker-entrypoint.d/10-ipv6* was added by nginx to do some IPv6 magic (which breaks the image) +RUN set -eux \ + && rm -rf /docker-entrypoint.d || true \ + && 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/nginx/nginx.conf /etc/nginx/nginx.conf +COPY ./data/vhost-gen/main.yml /etc/vhost-gen/main.yml +COPY ./data/vhost-gen/mass.yml /etc/vhost-gen/mass.yml +COPY ./data/vhost-gen/templates-main /etc/vhost-gen/templates-main +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.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-config-settings.sh b/Dockerfiles/data/docker-entrypoint.d/10-config-settings.sh similarity index 100% rename from data/docker-entrypoint.d/10-config-settings.sh rename to Dockerfiles/data/docker-entrypoint.d/10-config-settings.sh diff --git a/data/docker-entrypoint.d/11-supervisord.sh b/Dockerfiles/data/docker-entrypoint.d/11-supervisord.sh similarity index 100% rename from data/docker-entrypoint.d/11-supervisord.sh rename to Dockerfiles/data/docker-entrypoint.d/11-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/nginx/nginx.conf b/Dockerfiles/data/nginx/nginx.conf similarity index 100% rename from data/nginx/nginx.conf rename to Dockerfiles/data/nginx/nginx.conf 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/data/vhost-gen/templates-main/apache22.yml b/Dockerfiles/data/vhost-gen/templates-main/apache22.yml similarity index 100% rename from data/vhost-gen/templates-main/apache22.yml rename to Dockerfiles/data/vhost-gen/templates-main/apache22.yml diff --git a/data/vhost-gen/templates-main/apache24.yml b/Dockerfiles/data/vhost-gen/templates-main/apache24.yml similarity index 100% rename from data/vhost-gen/templates-main/apache24.yml rename to Dockerfiles/data/vhost-gen/templates-main/apache24.yml diff --git a/data/vhost-gen/templates-main/nginx.yml b/Dockerfiles/data/vhost-gen/templates-main/nginx.yml similarity index 100% rename from data/vhost-gen/templates-main/nginx.yml rename to Dockerfiles/data/vhost-gen/templates-main/nginx.yml diff --git a/Makefile b/Makefile index ff96fff..4baca41 100644 --- a/Makefile +++ b/Makefile @@ -27,9 +27,18 @@ TAG = latest NAME = Nginx VERSION = mainline IMAGE = devilbox/nginx-$(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 06d3166..92446d8 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ **[devilbox/docker-nginx-mainline](https://github.com/devilbox/docker-nginx-mainline)** -**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 **[Nginx](https://hub.docker.com/_/nginx)** 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)**.