commit 7991b9e8661428bb7f0191e4d41b4a136b12b431 Author: Ask Bjørn Hansen Date: Sat Sep 23 01:44:27 2017 -0700 perlweb/static-misc: Another container to run non-pm.org static perl stuff diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fc37b50 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM quay.io/ntppool/base-os:v2.3 +USER root +WORKDIR /web +VOLUME /git +VOLUME /web/config +RUN apk update; apk add apache2 +RUN mkdir /run/apache2; chown apache /run/apache2 +RUN ln -s /dev/stderr /var/log/apache2/error.log +RUN ln -s /dev/stdout /var/log/apache2/access.log + +RUN echo "IncludeOptional /web/config/*.conf" >> /etc/apache2/httpd.conf +ADD run-httpd /run.sh +CMD /run.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..c1f2a8f --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# static-misc + +## Test locally + + docker build -t quay.io/perl/static-web:v0.1 . + git clone git@git.develooper.com:perl-static-misc.git git + + docker run -p 8000:80 -n static-misc \ + -v `pwd`/git:/git/static -v `pwd`/config:/web/config \ + -ti --rm quay.io/perl/static-web:v0.1 + +Test with + + curl -H 'Host: i.perl.org' localhost:8000 + +To get a shell in the container run + + docker exec -ti static-misc bash + +And then run `curl -H 'Host: i.perl.org' localhost` there. + +## Production image + +The "production image" is in https://quay.io/perl/static-web - the image +is "manually" built and pushed because I didn't want to give quay access +to all of this git repository. + + REV=v1.0 + IMAGE=quay.io/perl/static-web:$REV + docker build -t $IMAGE . && \ + docker push $IMAGE + diff --git a/ingress.tmpl b/ingress.tmpl new file mode 100644 index 0000000..7da1653 --- /dev/null +++ b/ingress.tmpl @@ -0,0 +1,39 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: static-misc + annotations: + kubernetes.io/tls-acme: "true" + kubernetes.io/ingress.class: nginx + +{{- \$js := (json "ingress-hosts.json") }} +{{- \$hosts := (\$js | pointer "/Hosts") }} +{{- \$tls := (\$js | pointer "/tls") }} + +spec: + rules: + {{block "hosts" \$hosts}}{{ range . }} + - host: {{ . }} + http: + paths: + - path: / + backend: + serviceName: static-misc + servicePort: 80 + {{end}} + {{end}} + + {{ if \$tls }} + {{- range \$g, \$h := \$tls }} + {{ template "hosts" \$h }} + {{- end }} + + tls: + {{ range \$g, \$h := \$tls }} + - hosts: + {{ range \$h -}} + - {{ . }} + {{ end -}} + secretName: {{ \$g }}-tls + {{ end }} + {{ end }} diff --git a/run-httpd b/run-httpd new file mode 100755 index 0000000..f00cd30 --- /dev/null +++ b/run-httpd @@ -0,0 +1,12 @@ +#!/bin/sh +set -ex + +if [ ! -z "$READY_FILE" ]; then + while [ ! -e $READY_FILE ]; do + echo waiting for $READY_FILE + sleep 10 + done +fi + +exec httpd -DFOREGROUND -e info +#exec httpd -DFOREGROUND -e debug