Skip to content

Commit

Permalink
Merge pull request #45 from devilbox/release-0.44
Browse files Browse the repository at this point in the history
Add Alpine Docker flavour
  • Loading branch information
cytopia committed Mar 27, 2022
2 parents 33eb176 + 9cb9878 commit 7c6ad51
Show file tree
Hide file tree
Showing 25 changed files with 251 additions and 10 deletions.
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
7 changes: 7 additions & 0 deletions .github/workflows/params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ env:
{
"NAME": "Apache",
"VERSION": ["2.2"],
"FLAVOUR": ["latest", "debian"],
"ARCH": ["linux/amd64", "linux/386", "linux/arm64", "linux/arm/v7", "linux/arm/v6"]
},
{
"NAME": "Apache",
"VERSION": ["2.2"],
"FLAVOUR": ["alpine"],
"ARCH": ["linux/amd64"]
}
]
Expand Down
218 changes: 218 additions & 0 deletions Dockerfiles/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
FROM alpine:3.5 as builder

RUN set -eux \
&& apk add -U shadow


FROM httpd:2.2-alpine
MAINTAINER "cytopia" <[email protected]>

LABEL \
name="cytopia's apache 2.2 image" \
image="devilbox/apache-2.2" \
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
ARG ARCH

ENV BUILD_DEPS \
autoconf \
gcc \
musl-dev \
make \
wget

ENV RUN_DEPS \
ca-certificates \
bash \
openssl \
py-yaml \
supervisor


###
### Runtime arguments
###
ENV MY_USER=daemon
ENV MY_GROUP=daemon
ENV HTTPD_START="httpd-foreground"
ENV HTTPD_RELOAD="/usr/local/apache2/bin/httpd -k stop"

###
### Install required packages
###
RUN set -eux \
&& apk add -U \
${BUILD_DEPS} \
${RUN_DEPS} \
\
# Required symlinks to build mod-proxy-fcgi on i386
&& if [ "${ARCH}" = "linux/386" ]; then \
ln -s $(which ar) /usr/bin/i586-linux-gnu-ar; \
ln -s $(which ranlib) /usr/bin/i586-linux-gnu-ranlib ; \
fi \
\
# mod-proxy-fcgi
&& wget --no-check-certificate -O mod-proxy-fcgi.tar.gz https://github.com/devilbox/mod-proxy-fcgi/archive/master.tar.gz \
&& tar xvfz mod-proxy-fcgi.tar.gz \
&& cd mod-proxy-fcgi-master \
&& autoconf \
&& ./configure \
&& make \
&& make install \
&& cd .. \
&& rm -rf mod-proxy-fcgi* \
\
# 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 \
&& ( \
echo "ServerName localhost"; \
echo "LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so"; \
echo "NameVirtualHost *:80"; \
echo "Include conf/extra/httpd-default.conf"; \
echo "Include /etc/httpd-custom.d/*.conf"; \
echo "Include /etc/httpd/conf.d/*.conf"; \
echo "Include /etc/httpd/vhost.d/*.conf"; \
\
#echo "LoadModule ssl_module modules/mod_ssl.so"; \
echo "Listen 443"; \
echo "NameVirtualHost *:443"; \
echo "SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES"; \
echo "SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES"; \
echo "SSLHonorCipherOrder on"; \
echo "SSLProtocol all -SSLv2 -SSLv3"; \
echo "SSLProxyProtocol all -SSLv2 -SSLv3"; \
echo "SSLPassPhraseDialog builtin"; \
echo "SSLSessionCache \"shmcb:/usr/local/apache2/logs/ssl_scache(512000)\""; \
echo "SSLSessionCacheTimeout 300"; \
echo "SSLMutex \"file:/usr/local/apache2/logs/ssl_mutex\""; \
\
echo "HTTPProtocolOptions unsafe"; \
) >> /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


###
### 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


###
### Backporting from Alpine 3.5
###
# Required for usermod and groupmod
COPY --from=builder /etc/pam.d /etc/pam.d
COPY --from=builder /etc/security /etc/security
COPY --from=builder /etc/login.defs /etc/login.defs

COPY --from=builder /lib/security /lib/security
COPY --from=builder /lib/libpam.so.0 /lib/libpam.so.0
COPY --from=builder /lib/libpam.so.0.84.1 /lib/libpam.so.0.84.1
COPY --from=builder /lib/libpam_misc.so.0 /lib/libpam_misc.so.0
COPY --from=builder /lib/libpam_misc.so.0.82.1 /lib/libpam_misc.so.0.82.1
COPY --from=builder /lib/libpamc.so.0 /lib/libpamc.so.0
COPY --from=builder /lib/libpamc.so.0.82.1 /lib/libpamc.so.0.82.1

#COPY --from=builder /usr/bin/faillog /usr/bin/faillog
#COPY --from=builder /usr/bin/gpasswd /usr/bin/gpasswd
#COPY --from=builder /usr/bin/sg /usr/bin/sg
#COPY --from=builder /usr/bin/chfn /usr/bin/chfn
#COPY --from=builder /usr/bin/newgrp /usr/bin/newgrp
#COPY --from=builder /usr/bin/chsh /usr/bin/chsh
#COPY --from=builder /usr/bin/lastlog /usr/bin/lastlog
#COPY --from=builder /usr/bin/chage /usr/bin/chage
#COPY --from=builder /usr/bin/expiry /usr/bin/expiry
#COPY --from=builder /usr/sbin/newusers /usr/sbin/newusers
#COPY --from=builder /usr/sbin/pwconv /usr/sbin/pwconv
#COPY --from=builder /usr/sbin/groupmems /usr/sbin/groupmems
#COPY --from=builder /usr/sbin/vipw /usr/sbin/vipw
COPY --from=builder /usr/sbin/usermod /usr/sbin/usermod
#COPY --from=builder /usr/sbin/grpconv /usr/sbin/grpconv
#COPY --from=builder /usr/sbin/useradd /usr/sbin/useradd
COPY --from=builder /usr/sbin/groupmod /usr/sbin/groupmod
#COPY --from=builder /usr/sbin/grpck /usr/sbin/grpck
#COPY --from=builder /usr/sbin/userdel /usr/sbin/userdel
#COPY --from=builder /usr/sbin/groupdel /usr/sbin/groupdel
#COPY --from=builder /usr/sbin/pwck /usr/sbin/pwck
#COPY --from=builder /usr/sbin/pwunconv /usr/sbin/pwunconv
#COPY --from=builder /usr/sbin/chgpasswd /usr/sbin/chgpasswd
#COPY --from=builder /usr/sbin/logoutd /usr/sbin/logoutd
#COPY --from=builder /usr/sbin/grpunconv /usr/sbin/grpunconv
#COPY --from=builder /usr/sbin/vigr /usr/sbin/vigr
#COPY --from=builder /usr/sbin/groupadd /usr/sbin/groupadd
#COPY --from=builder /bin/groups /bin/groups


###
### 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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 = Apache
VERSION = 2.2
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


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-apache-2.2](https://github.com/devilbox/docker-apache-2.2)**

**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.2](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)**.

Expand Down
11 changes: 8 additions & 3 deletions tests/00.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,32 @@ run "echo \"hello world\" > ${RAND_DIR}/index.html"
###
### Startup container
###
run "docker run -d --rm --platform ${ARCH} \
run "docker run --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
run "docker stop ${RAND_NAME}" || true
exit 21
fi
if ! run "curl -sS localhost/index.html"; then
run "docker logs ${RAND_NAME}" || true
run "docker stop ${RAND_NAME}"
exit 1
fi
if ! run "curl -sS localhost/index.html | grep 'hello world'"; then
run "docker logs ${RAND_NAME}" || true
run "docker stop ${RAND_NAME}"
exit 1
fi
Expand Down

0 comments on commit 7c6ad51

Please sign in to comment.