diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 16e22df..0000000 --- a/.drone.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -kind: pipeline -name: deploy to swarm-test.autonomic.zone -steps: - - name: deployment - image: git.coopcloud.tech/coop-cloud/stack-ssh-deploy:latest - settings: - host: swarm-test.autonomic.zone - stack: federatedwiki - generate_secrets: true - purge: true - deploy_key: - from_secret: drone_ssh_swarm_test - networks: - - proxy - environment: - DOMAIN: federatedwiki.swarm-test.autonomic.zone - STACK_NAME: federatedwiki - LETS_ENCRYPT_ENV: production - INSTALL_SH_VERSION: v1 - CONFIG_JSON_VERSION: v1 - CONFIG_OWNER_JSON_VERSION: v1 -trigger: - branch: - - main ---- -kind: pipeline -name: generate recipe catalogue -steps: - - name: release a new version - image: plugins/downstream - settings: - server: https://build.coopcloud.tech - token: - from_secret: drone_abra-bot_token - fork: true - repositories: - - coop-cloud/auto-recipes-catalogue-json - -trigger: - event: tag diff --git a/.env.sample b/.env.sample deleted file mode 100644 index 0f41533..0000000 --- a/.env.sample +++ /dev/null @@ -1,26 +0,0 @@ -TYPE=federatedwiki - -DOMAIN=federatedwiki.example.com -## Domain aliases -#EXTRA_DOMAINS=', `www.federatedwiki.example.com`' -LETS_ENCRYPT_ENV=production - -COMPOSE_FILE="compose.yml" - -# Change to an absolute path to use a bind-mount, e.g. /opt/fedwiki -FEDWIKI_VOLUME="fedwiki" - -# custom wiki.cafe image, for working oauth2 support -#COMPOSE_FILE="$COMPOSE_FILE:compose.wikicafe.yml" - -# Predefined "owner" security -#COMPOSE_FILE="$COMPOSE_FILE:compose.owner.yml" - -# persistent lib volume / node_modules directory, e.g. for plugmatic -#COMPOSE_FILE="$COMPOSE_FILE:compose.lib.yml" - -COOKIE_SECRET="asflkjqpweoriuwpeogdjgbpdofigh" -AUTHOR="Baja Colorado" -ADMIN_KEY="" - -FEDWIKI_IS_PRIVATE=0 diff --git a/.gitignore b/.gitignore index 37b52cc..e6905a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/.envrc +.env* \ No newline at end of file diff --git a/README.md b/README.md index 30f8cef..0e2433c 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,24 @@ -# Federated Wiki +# Fedwiki -Share pages circulating within a creative commons +Wiki Cafe's configuration for a Nextcloud deployment. Originally slimmed down from an `abra` [recipe](https://git.coopcloud.tech/coop-cloud/federatedwiki) by [Co-op Cloud](https://coopcloud.tech/). - -* **Category**: Apps -* **Status**: 0, work-in-progress -* **Image**: [`dobbs/farm`](https://hub.docker.com/r/dobbs/farm/), 4, upstream -* **Healthcheck**: No -* **Backups**: No -* **Email**: No -* **Tests**: No -* **SSO**: No - -## Basic usage +## Deploying the app with Docker Swarm -1. Set up Docker Swarm and [`abra`] -2. Deploy [`coop-cloud/traefik`] -3. `abra app new federatedwiki` -4. `abra app config YOURAPPDOMAIN` - be sure to change `DOMAIN` to something that resolves to - your Docker swarm box -5. `abra app deploy YOURAPPDOMAIN` +Set the environment variables from the .env file during the shell session. -[`abra`]: https://git.autonomic.zone/autonomic-cooperative/abra -[`coop-cloud/traefik`]: https://git.autonomic.zone/coop-cloud/traefik +``` +set -a && source .env && set +a +``` + +Set the secrets. + +``` +printf "SECRET_HERE" | docker secret create SECRET_NAME - +``` + +Deploy using the `-c` flag to specify one or multiple compose files. + +``` +docker stack deploy fedwiki --detach=true -c compose.yaml +``` \ No newline at end of file diff --git a/abra.sh b/abra.sh deleted file mode 100644 index 7ae0733..0000000 --- a/abra.sh +++ /dev/null @@ -1,23 +0,0 @@ -export INSTALL_SH_VERSION=v9 -export CONFIG_JSON_VERSION=v7 -export CONFIG_OWNER_JSON_VERSION=v4 - -abra_backup_app() { - _abra_backup_dir "app:/home/node/.wiki" -} - -abra_restore_app() { - # shellcheck disable=SC2034 - { - abra__src_="-" - abra__dst_="app:/home/node/.wiki" - } - - zcat "$@" | sub_app_cp - - success "Restored 'app'" -} - -abra_backup() { - abra_backup_app -} diff --git a/compose.lib.yaml b/compose.lib.yaml new file mode 100644 index 0000000..c74a7aa --- /dev/null +++ b/compose.lib.yaml @@ -0,0 +1,7 @@ +services: + app: + volumes: + - "lib:/home/node/lib" + +volumes: + lib: diff --git a/compose.lib.yml b/compose.lib.yml deleted file mode 100644 index 5de1e75..0000000 --- a/compose.lib.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -version: "3.8" - -services: - app: - volumes: - - "fedwiki_lib:/home/node/lib" - -volumes: - fedwiki_lib: diff --git a/compose.owner.yml b/compose.owner.yml deleted file mode 100644 index 678205a..0000000 --- a/compose.owner.yml +++ /dev/null @@ -1,15 +0,0 @@ - ---- -version: "3.8" - -services: - app: - configs: - - source: config_owner_json_conf - target: /home/node/config/config.owner.json - -configs: - config_owner_json_conf: - name: ${STACK_NAME}_config_owner_json_${CONFIG_OWNER_JSON_VERSION} - file: config.owner.json.tmpl - template_driver: golang diff --git a/compose.wikicafe.yml b/compose.wikicafe.yml deleted file mode 100644 index 7b267f5..0000000 --- a/compose.wikicafe.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -version: "3.8" - -services: - app: - image: git.coopcloud.tech/wiki-cafe/wiki-farm:latest diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..e76eb41 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,74 @@ +services: + app: + image: git.coopcloud.tech/wiki-cafe/fedwiki-oci-image:0.39.4-1 + command: /bin/sh entrypoint.sh + volumes: + - "data:/home/node/.wiki" + networks: + - proxy + configs: + - source: entrypoint_sh_conf + target: /home/node/entrypoint.sh + - source: config_json_initial_conf + target: /home/node/initial-config/config.json + secrets: + - cookie_secret + environment: + - DOMAIN + - DOMAINS + - COOKIE_SECRET + - AUTHOR + - ADMIN_KEY + deploy: + update_config: + order: start-first + restart_policy: + condition: on-failure + labels: + - "traefik.enable=true" + - "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=3000" + - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`) || HostRegexp(`{subdomain:\\w+}.${DOMAIN}`)" + - "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure" + - "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}" + - "traefik.http.routers.${STACK_NAME}.tls.domains[0].main=${DOMAIN}" + - "traefik.http.routers.${STACK_NAME}.tls.domains[0].sans=*.${DOMAIN}" + - "traefik.http.routers.${STACK_NAME}.priority=1" + - "traefik.http.routers.${STACK_NAME}_auth.rule=(Host(`${DOMAIN}`) && (PathPrefix(`/auth`) || Path(`/security/dialog.css`)))" + - "traefik.http.routers.${STACK_NAME}_auth.entrypoints=web-secure" + - "traefik.http.routers.${STACK_NAME}_auth.tls.certresolver=${LETS_ENCRYPT_ENV}" + - "caddy_0=https://${DOMAIN}" + - "caddy_0.tls.on_demand=" + - "caddy_0.@match.path=/auth/* /security/dialog.css" + - "caddy_0.reverse_proxy= @match {{upstreams 3000}}" + - ${DOMAINS} + - "caddy_1.reverse_proxy={{upstreams 3000}}" + - "caddy_1.tls.on_demand=" + - "backupbot.backup=true" + - "backupbot.backup.path=/home/node/.wiki" + healthcheck: + test: "node -e 'var http = require(\"http\"); var options = { host : \"localhost\", port : \"3000\", timeout : 2000, path : \"/view/welcome-visitors\", headers: { \"Host\": \"${DOMAIN}\" } }; var request = http.request(options, (res) => { console.log(`STATUS: $${res.statusCode}`); if (res.statusCode == 200) { process.exit(0); } else { process.exit(1); } }); request.on(\"error\", function(err) { console.log('ERROR'); process.exit(1); }); request.end();'" + interval: 10s + timeout: 2s + retries: 2 + start_period: 30s + +volumes: + data: + +networks: + proxy: + external: true + +secrets: + cookie_secret: + external: true + name: ${STACK_NAME}_cookie_secret + +configs: + entrypoint_sh_conf: + name: ${STACK_NAME}_entrypoint_sh + file: entrypoint.sh + config_json_initial_conf: + name: ${STACK_NAME}_config_initial_json + file: config.initial.json.tmpl + template_driver: golang diff --git a/compose.yml b/compose.yml deleted file mode 100644 index 5a0f3c5..0000000 --- a/compose.yml +++ /dev/null @@ -1,63 +0,0 @@ ---- -version: "3.8" - -services: - app: - image: dobbs/farm:1.0.18 - command: /bin/sh config/install.sh - volumes: - - "fedwiki_friends:/home/node/config" - - "${FEDWIKI_VOLUME}:/home/node/.wiki" - networks: - - proxy - configs: - - source: install_sh_conf - target: /home/node/config/install.sh - - source: config_json_conf - target: /home/node/config/config.json - environment: - - DOMAIN - - COOKIE_SECRET - - AUTHOR - - ADMIN_KEY - deploy: - restart_policy: - condition: on-failure - labels: - - "traefik.enable=true" - - "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=3000" - - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`) || HostRegexp(`{subdomain:\\w+}.${DOMAIN}`)" - - "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure" - - "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}" - - "traefik.http.routers.${STACK_NAME}.tls.domains[0].main=${DOMAIN}" - - "traefik.http.routers.${STACK_NAME}.tls.domains[0].sans=*.${DOMAIN}" - - "traefik.http.routers.${STACK_NAME}.priority=1" - - "caddy=https://${DOMAIN}, https://*.${DOMAIN}, https://*.*.${DOMAIN}, https://*.*.*.${DOMAIN}" - - "caddy.reverse_proxy={{upstreams 3000}}" - - "caddy.tls.on_demand=" - - "backupbot.backup=true" - - "backupbot.backup.path=/home/node/.wiki" - - "coop-cloud.${STACK_NAME}.version=1.0.1+1.0.18" - # healthcheck: - # test: ["CMD", "curl", "-f", "http://localhost"] - # interval: 30s - # timeout: 10s - # retries: 10 - # start_period: 1m - -volumes: - fedwiki: - fedwiki_friends: - -networks: - proxy: - external: true - -configs: - install_sh_conf: - name: ${STACK_NAME}_install_sh_${INSTALL_SH_VERSION} - file: install.sh - config_json_conf: - name: ${STACK_NAME}_config_json_${CONFIG_JSON_VERSION} - file: config.json.tmpl - template_driver: golang diff --git a/config.initial.json.tmpl b/config.initial.json.tmpl new file mode 100644 index 0000000..b10cadc --- /dev/null +++ b/config.initial.json.tmpl @@ -0,0 +1,6 @@ +{ + "farm": true, + "cookieSecret": "{{ secret "cookie_secret" }}", + "security_useHttps": true, + "security_type": "friends" +} \ No newline at end of file diff --git a/config.json.tmpl b/config.json.tmpl deleted file mode 100644 index 01a9642..0000000 --- a/config.json.tmpl +++ /dev/null @@ -1,14 +0,0 @@ -{ - "admin": "{{ env "ADMIN_KEY" }}", - "farm": true, - "cookieSecret": "{{ env "COOKIE_SECRET" }}", - "secure_cookie": true, - "security_type": "friends" - {{ if eq (env "FEDWIKI_IS_PRIVATE") "1" }}, - "wikiDomains": { - "$DOMAIN": { - "id": "/home/node/.wiki/config.owner.json" - } - } - {{ end }} -} diff --git a/config.owner.json.tmpl b/config.owner.json.tmpl deleted file mode 100644 index 0dae8e9..0000000 --- a/config.owner.json.tmpl +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "{{ env "AUTHOR" }}", - "friend": { - "secret": "{{ env "PASSWORD" }}" - } -} diff --git a/install.sh b/entrypoint.sh similarity index 51% rename from install.sh rename to entrypoint.sh index 62b588a..fe1d99c 100644 --- a/install.sh +++ b/entrypoint.sh @@ -4,8 +4,4 @@ if [ ! -f .wiki/config.json ]; then cp config/config.json .wiki/config.json fi -if [ ! -f .wiki/config.owner.json ]; then - cp config/config.owner.json .wiki/config.owner.json -fi - wiki --farm diff --git a/release/1.0.0+1.0.18 b/release/1.0.0+1.0.18 deleted file mode 100644 index 1d777c6..0000000 --- a/release/1.0.0+1.0.18 +++ /dev/null @@ -1,7 +0,0 @@ -WARNING! 🚨 - -There is a new mandatory config option, FEDWIKI_VOLUME -- please copy the -default value from the recipe .env.sample to your .env file on upgrade. - -If you haven't done that yet, best to bail with Ctrl+C, then add the option, -then re-run this `abra app upgrade ...` command