From e8ec567f43c28f7863cfacbadb982268bf0683ae Mon Sep 17 00:00:00 2001 From: Cassowary Rusnov Date: Wed, 26 Oct 2022 17:26:30 -0700 Subject: [PATCH] Initial setup based on custom-html --- .env.sample | 17 +++++++++++++++++ README.md | 36 ++++++++++++++++++++++++++++++++++++ abra.sh | 1 + compose.git-pull.yml | 27 +++++++++++++++++++++++++++ compose.sso.yml | 8 ++++++++ compose.yml | 39 +++++++++++++++++++++++++++++++++++++++ entrypoint.git-pull.sh | 11 +++++++++++ 7 files changed, 139 insertions(+) create mode 100644 .env.sample create mode 100644 README.md create mode 100644 abra.sh create mode 100644 compose.git-pull.yml create mode 100644 compose.sso.yml create mode 100644 compose.yml create mode 100644 entrypoint.git-pull.sh diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..c3b995b --- /dev/null +++ b/.env.sample @@ -0,0 +1,17 @@ +TYPE=custom-html + +DOMAIN=custom-html.example.com +## Domain aliases +#EXTRA_DOMAINS=', `www.custom-html.example.com`' +LETS_ENCRYPT_ENV=production + +COMPOSE_FILE="compose.yml" + +# Single Sign On via Traefik "file provider" +#COMPOSE_FILE="$COMPOSE_FILE:compose.sso.yml" + +# Git-pull regularly +#COMPOSE_FILE="$COMPOSE_FILE:compose.git-pull.yml" +#GIT_REPO_URL="https://git.coopcloud.tech/dalmationer/hexbomb.gay" +#CRON_SCHEDULE="*/1 * * * *" +#GIT_REPO_SUBDIR="" diff --git a/README.md b/README.md new file mode 100644 index 0000000..ad06534 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# Custom HTML + +Custom HTML website, served using thttpd + + +* **Category**: Apps +* **Status**: 1, pre-alpha +* **Image**: [`thttpd`](https://hub.docker.com/r/dragas/thttpd), 1, 3rd party +* **Healthcheck**: No +* **Backups**: No +* **Email**: N/A +* **Tests**: 0 +* **SSO**: Yes + + +## Basic usage + +1. Set up Docker Swarm and [`abra`] +2. Deploy [`coop-cloud/traefik`] +3. `abra app new custom-html` +4. `abra app YOURAPPDOMAIN config` - be sure to change `$DOMAIN` to something that resolves to + your Docker swarm box +5. `abra app YOURAPPDOMAIN deploy` +6. Copy your files to the container, using something like +``` +abra app YOURAPPDOMAIN cp index.html app:/content +``` + +[`abra`]: https://git.autonomic.zone/autonomic-cooperative/abra +[`coop-cloud/traefik`]: https://git.autonomic.zone/coop-cloud/traefik + +## Git Based Usage + +1. Set up as above except for step 6. +2. Deploy `swarm-cronjob` to the host +2. `abra app config`, Uncomment Git lines in configuration, and set variables as appropriate. diff --git a/abra.sh b/abra.sh new file mode 100644 index 0000000..11ca18f --- /dev/null +++ b/abra.sh @@ -0,0 +1 @@ +export ENTRYPOINT_CONF_VERSION=v3 diff --git a/compose.git-pull.yml b/compose.git-pull.yml new file mode 100644 index 0000000..9e30a92 --- /dev/null +++ b/compose.git-pull.yml @@ -0,0 +1,27 @@ +version: "3.8" +services: + git: + environment: + - GIT_REPO_URL + - GIT_REPO_SUBDIR + image: alpine/git:v2.32.0 + entrypoint: /docker-entrypoint.sh + volumes: + - content:/git/${GIT_REPO_SUBDIR} + configs: + - source: entrypoint_conf + target: /docker-entrypoint.sh + mode: 0555 + deploy: + mode: replicated + replicas: 0 + labels: + - "swarm.cronjob.enable=true" + - "swarm.cronjob.schedule=${CRON_SCHEDULE:-*/5 * * * *}" + restart_policy: + condition: none + +configs: + entrypoint_conf: + name: ${STACK_NAME}_entrypoint_conf_${ENTRYPOINT_CONF_VERSION} + file: entrypoint.git-pull.sh diff --git a/compose.sso.yml b/compose.sso.yml new file mode 100644 index 0000000..385457b --- /dev/null +++ b/compose.sso.yml @@ -0,0 +1,8 @@ +version: "3.8" +services: + app: + environment: + - TFA_MIDDLEWARE_NAME + deploy: + labels: + - "traefik.http.routers.${STACK_NAME}.middlewares=${TFA_MIDDLEWARE_NAME}@file" diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..046ddd1 --- /dev/null +++ b/compose.yml @@ -0,0 +1,39 @@ +--- +version: "3.8" + +services: + app: + image: dragas/thttpd + networks: + - proxy + deploy: + restart_policy: + condition: on-failure + labels: + - "traefik.enable=true" + - "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=80" + - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})" + - "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure" + - "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}" + # Redirect from EXTRA_DOMAINS to DOMAIN + - "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect" + - "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true" + - "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}" + - "coop-cloud.${STACK_NAME}.version=1.2.1+1.21.6" + environment: + volumes: + - content:/var/www/http + configs: + #healthcheck: + # test: ["CMD", "curl", "-f", "http://localhost"] + # interval: 30s + # timeout: 10s + # retries: 10 + # start_period: 1m + +volumes: + content: + +networks: + proxy: + external: true diff --git a/entrypoint.git-pull.sh b/entrypoint.git-pull.sh new file mode 100644 index 0000000..16682ef --- /dev/null +++ b/entrypoint.git-pull.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ ! -d /git/.git ]; then + echo "No repo found, emptying /git/ directory" + rm -r /git/* + echo "Cloning $GIT_REPO_URL into /git" + git clone "$GIT_REPO_URL" /git +else + echo "Updating /git" + git pull +fi