diff --git a/compose.owner.yaml b/compose.owner.yaml deleted file mode 100644 index 10ee306..0000000 --- a/compose.owner.yaml +++ /dev/null @@ -1,11 +0,0 @@ -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 - file: config.owner.json.tmpl - template_driver: golang diff --git a/compose.yaml b/compose.yaml index 689443a..c0193d0 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,23 +1,26 @@ services: app: - image: dobbs/farm:1.0.18 - command: /bin/sh config/install.sh + image: dobbs/farm:1.0.20 + command: /bin/sh entrypoint.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 + - 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 - COOKIE_SECRET - AUTHOR - ADMIN_KEY deploy: + update_config: + order: start-first restart_policy: condition: on-failure labels: @@ -34,26 +37,32 @@ services: - "caddy.tls.on_demand=" - "backupbot.backup=true" - "backupbot.backup.path=/home/node/.wiki" - # healthcheck: - # test: ["CMD", "curl", "-f", "http://localhost"] - # interval: 30s - # timeout: 10s - # retries: 10 - # start_period: 1m + 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: fedwiki: - fedwiki_friends: networks: proxy: external: true +secrets: + cookie_secret: + external: true + name: ${STACK_NAME}_cookie_secret + configs: - install_sh_conf: - name: ${STACK_NAME}_install_sh - file: install.sh - config_json_conf: - name: ${STACK_NAME}_config_json - file: config.json.tmpl + 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/config.initial.json.tmpl b/config.initial.json.tmpl new file mode 100644 index 0000000..c6d5146 --- /dev/null +++ b/config.initial.json.tmpl @@ -0,0 +1,6 @@ +{ + "farm": true, + "cookieSecret": "{{ secret "cookie_secret" }}", + "secure_cookie": 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