Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/action_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/action_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/action_schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env:
{
"NAME": "Nginx",
"VERSION": ["stable"],
"FLAVOUR": ["latest", "debian", "alpine"],
"ARCH": ["linux/amd64", "linux/386", "linux/arm64", "linux/arm/v7", "linux/arm/v6"]
}
]
Expand Down
128 changes: 128 additions & 0 deletions Dockerfiles/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
FROM nginx:stable-alpine
MAINTAINER "cytopia" <cytopia@everythingcli.org>

LABEL \
name="cytopia's nginx stable image" \
image="devilbox/nginx-stable" \
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"]
File renamed without changes.
1 change: 1 addition & 0 deletions Dockerfiles/Dockerfile.latest
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@ TAG = latest
NAME = Nginx
VERSION = stable
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


Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

**[devilbox/docker-nginx-stable](https://github.com/devilbox/docker-nginx-stable)**

**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)**.

Expand Down
8 changes: 5 additions & 3 deletions tests/00.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,24 @@ run "echo \"hello world\" > ${RAND_DIR}/index.html"
###
### Startup container
###
run "docker run -d --rm --platform ${ARCH} \
run "docker run --rm --platform ${ARCH} \
-v ${RAND_DIR}:/var/www/default/htdocs \
-p 127.0.0.1:80:80 \
-e DEBUG_ENTRYPOINT=2 \
-e DEBUG_RUNTIME=1 \
-e NEW_UID=$( id -u ) \
-e NEW_GID=$( id -g ) \
--name ${RAND_NAME} ${IMAGE}:${TAG}"
--name ${RAND_NAME} ${IMAGE}:${TAG} &"


###
### Tests
###
run "sleep 20" # Startup-time is longer on cross-platform
run "docker ps"
run "docker logs ${RAND_NAME}"
if ! run "docker logs ${RAND_NAME}"; then
exit 1
fi
if ! run "curl -sS localhost/index.html"; then
run "docker stop ${RAND_NAME}"
exit 1
Expand Down