Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Balena traefik ssl
version: '2'
services:
traefik:
build:
context: traefik
dockerfile: Dockerfile.template
command:
- --entrypoints.web.address=:80
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --providers.docker.endpoint=unix:///var/run/balena.sock
- --entrypoints.websecure.address=:443
- --certificatesresolvers.le.acme.email=YOUR@email.com
- --certificatesresolvers.le.acme.storage=/certs/acme.json
- --certificatesresolvers.le.acme.tlschallenge=true
- --certificatesResolvers.le.acme.httpChallenge.entryPoint=web
-
volumes:
- "certs:/certs"
labels:
- "io.balena.features.balena-socket=true"
ports:
- "443:443"
- "80:80"
www:
build:
context: minifier
dockerfile: Dockerfile.template
labels:
- traefik.enable=true
- traefik.http.routers.my-app.rule=Host(`YOURSSLDOMAIN.com`)
- traefik.http.routers.my-app.tls.certresolver=le
- traefik.http.routers.my-app.entrypoints=websecure
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
volumes:
certs:
----
Dockerfile.template traefik
ARG BALENA_MACHINE_NAME="%%BALENA_MACHINE_NAME%%"
FROM balenalib/${BALENA_MACHINE_NAME}-alpine:3.11
RUN apk --no-cache add ca-certificates tzdata
RUN set -ex; \
apkArch="$(apk --print-arch)"; \
case "$apkArch" in \
armhf) arch='armv6' ;; \
armv7) arch='armv7' ;; \
aarch64) arch='arm64' ;; \
x86_64) arch='amd64' ;; \
*) echo >&2 "error: unsupported architecture: $apkArch"; exit 1 ;; \
esac; \
wget --quiet -O /tmp/traefik.tar.gz "https://github.com/containous/traefik/releases/download/v2.2.1/traefik_v2.2.1_linux_$arch.tar.gz"; \
tar xzvf /tmp/traefik.tar.gz -C /usr/local/bin traefik; \
rm -f /tmp/traefik.tar.gz; \
chmod +x /usr/local/bin/traefik
COPY entrypoint.sh /
EXPOSE 80
ENTRYPOINT ["/entrypoint.sh"]
CMD ["traefik"]
# Metadata
LABEL org.opencontainers.image.vendor="Containous" \
org.opencontainers.image.url="https://traefik.io" \
org.opencontainers.image.title="Traefik" \
org.opencontainers.image.description="A modern reverse-proxy" \
org.opencontainers.image.version="v2.2.1" \
org.opencontainers.image.documentation="https://docs.traefik.io"
----
Dockerfile.template from minifier
MUST HAVE
EXPOSE 80 for example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment