diff --git a/.env.sample b/.env.sample index 77a978b..f35d407 100644 --- a/.env.sample +++ b/.env.sample @@ -1,6 +1,6 @@ -TYPE=baserow +TYPE=formio -DOMAIN=baserow.example.com +DOMAIN=formio.example.com COMPOSE_FILE="compose.yml" @@ -13,3 +13,5 @@ COMPOSE_FILE="compose.yml" LETS_ENCRYPT_ENV=production ROOT_EMAIL="admin@example.com" +SECRET_ROOT_PASS_VERSION=v1 +SECRET_MONGO_PASS_VERSION=v1 \ No newline at end of file diff --git a/abra.sh b/abra.sh index 6d93447..4fc5491 100644 --- a/abra.sh +++ b/abra.sh @@ -1 +1 @@ -export PG_BACKUP_CONFIG_VERSION=v1 \ No newline at end of file +export CUSTOM_ENTRYPOINT_VERSION=v1 \ No newline at end of file diff --git a/compose.yml b/compose.yml index 7a8a13a..5bf1ce1 100644 --- a/compose.yml +++ b/compose.yml @@ -9,10 +9,11 @@ services: - internal environment: DEBUG: formio:* - NODE_CONFIG: '{"mongo": "mongodb://mongo:27017/formio"}' - ROOT_PASSWORD_FILE: annoying +# NODE_CONFIG: '{"mongo": "mongodb://mongo:27017/formio"}' + ROOT_PASSWORD_FILE: "/run/secrets/root_pass" secrets: - root_pass + - mongo_pass deploy: restart_policy: condition: on-failure @@ -39,10 +40,12 @@ services: # retries: 10 # start_period: 1m configs: - - source: backup-postgres - target: /backup.sh + - source: custom-entrypoint + target: /custom-entrypoint.sh mode: 0777 - mongodb: + entrypoint: /custom-entrypoint.sh + + mongo: image: mongo:8.2.6 networks: - internal @@ -51,18 +54,29 @@ services: environment: MONGO_INITDB_ROOT_USERNAME: "root" MONGO_INITDB_ROOT_PASSWORD_FILE: "/run/secrets/mongo_pass" + MONGO_INITDB_DATABASE: formio + configs: + - source: mongo-init + target: /docker-entrypoint-initdb.d/mongo-init.js + mode: 0777 secrets: - mongo_pass - + volumes: data: configs: - backup-postgres: - name: backup-postgres_${PG_BACKUP_CONFIG_VERSION} - file: ./backup-postgres.sh + custom-entrypoint: + name: custom-entrypoint_${CUSTOM_ENTRYPOINT_VERSION} + file: ./custom-entrypoint.sh.tmpl + template_driver: golang + mongo-init: + name: mongo-init_${MONGO-INIT_VERSION} + file: ./mongo-init.js.tmpl + template_driver: golang networks: + internal: proxy: external: true diff --git a/custom-entrypoint.sh.tmpl b/custom-entrypoint.sh.tmpl new file mode 100644 index 0000000..456408e --- /dev/null +++ b/custom-entrypoint.sh.tmpl @@ -0,0 +1,7 @@ +#!/bin/sh +export ROOT_PASSWORD=`cat $ROOT_PASSWORD_FILE` +export NODE_CONFIG='{ + "mongo": "mongodb://formio:{{ secret "mongo_pass" }}@mongo:27017/formio", + "port": 3001 +}' +/usr/local/bin/docker-entrypoint.sh --no-node-snapshot main \ No newline at end of file diff --git a/mongo-init.js.tmpl b/mongo-init.js.tmpl new file mode 100644 index 0000000..0910ce0 --- /dev/null +++ b/mongo-init.js.tmpl @@ -0,0 +1,12 @@ +db.createUser( + { + user: "formio", + pwd: "{{ secret "mongo_pass" }}", + roles: [ + { + role: "readWrite", + db: "formio" + } + ] + } +);