Compare commits
39 Commits
0.3.0+2.8.
...
discourse-
| Author | SHA1 | Date | |
|---|---|---|---|
| ede639916c | |||
| 5f50022bb4 | |||
| a5a3b36755 | |||
| a081d1dba0 | |||
| f783d9988b | |||
| 0c4539b7ad | |||
| f87c612d71 | |||
| 2b28de444d | |||
| a9f08eed28 | |||
| 7e4d85a810 | |||
| b0f9ae743a | |||
| 5091fd999e | |||
| ec7bbdf786 | |||
| 0f873433ba | |||
| 7d53d4ec39 | |||
| ee2381c3b7 | |||
| 63d3801060 | |||
| fee61883ed | |||
| eb96de947b | |||
| ddda5da6bc | |||
| 304468b8f4 | |||
| 0ccf1d7a6c | |||
| 1049c27c35 | |||
| 03dc80d073 | |||
| 300f374af9 | |||
| ec72949bfa | |||
| 6a5f20bc8a | |||
| 3b5d789390 | |||
| 22b8f8f265 | |||
| 5868b83948 | |||
| 5bef03aabd | |||
| 0c7847ac15 | |||
| 7fc57c52a5 | |||
| fd24d4a328 | |||
| 1240106d4d | |||
| add7b1e240 | |||
| 802a22886c | |||
| d1fcc7a6fa | |||
|
41f7c0089e
|
BIN
.compose.yml.swp
BIN
.compose.yml.swp
Binary file not shown.
19
.drone.yml
19
.drone.yml
@ -3,7 +3,7 @@ kind: pipeline
|
|||||||
name: deploy to swarm-test.autonomic.zone
|
name: deploy to swarm-test.autonomic.zone
|
||||||
steps:
|
steps:
|
||||||
- name: deployment
|
- name: deployment
|
||||||
image: decentral1se/stack-ssh-deploy:latest
|
image: git.coopcloud.tech/coop-cloud/stack-ssh-deploy:latest
|
||||||
settings:
|
settings:
|
||||||
host: swarm-test.autonomic.zone
|
host: swarm-test.autonomic.zone
|
||||||
stack: discourse
|
stack: discourse
|
||||||
@ -18,6 +18,23 @@ steps:
|
|||||||
STACK_NAME: discourse
|
STACK_NAME: discourse
|
||||||
LETS_ENCRYPT_ENV: production
|
LETS_ENCRYPT_ENV: production
|
||||||
SECRET_DB_PASSWORD_VERSION: v1
|
SECRET_DB_PASSWORD_VERSION: v1
|
||||||
|
DB_ENTRYPOINT_VERSION: v1
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- main
|
- 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:
|
||||||
|
- toolshed/auto-recipes-catalogue-json
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event: tag
|
||||||
|
|||||||
26
.env.sample
26
.env.sample
@ -5,15 +5,25 @@ DOMAIN=discourse.example.com
|
|||||||
#EXTRA_DOMAINS=', `www.discourse.example.com`'
|
#EXTRA_DOMAINS=', `www.discourse.example.com`'
|
||||||
LETS_ENCRYPT_ENV=production
|
LETS_ENCRYPT_ENV=production
|
||||||
|
|
||||||
# Outgoing email
|
# Admin / developer accounts (comma-separated); these become admins on signup
|
||||||
#DISCOURSE_SMTP_HOST=
|
DISCOURSE_DEVELOPER_EMAILS=admin@example.com
|
||||||
#DISCOURSE_SMTP_PORT=
|
|
||||||
#DISCOURSE_SMTP_USER=
|
|
||||||
#DISCOURSE_SMTP_PROTOCOL=
|
|
||||||
#DISCOURSE_SMTP_AUTH=
|
|
||||||
|
|
||||||
# SMTP authentication
|
# Outgoing email (official discourse/discourse env names)
|
||||||
#COMPOSE_FILE="compose.yml:compose.smtpauth.yml"
|
#DISCOURSE_SMTP_ADDRESS=
|
||||||
|
#DISCOURSE_SMTP_PORT=587
|
||||||
|
#DISCOURSE_SMTP_USER_NAME=
|
||||||
|
#DISCOURSE_SMTP_AUTHENTICATION=login
|
||||||
|
#DISCOURSE_SMTP_ENABLE_START_TLS=true
|
||||||
|
# Set this if you send e-mail from a different address than noreply@$DOMAIN
|
||||||
|
#DISCOURSE_NOTIFICATION_EMAIL=
|
||||||
|
|
||||||
|
# SMTP password as a secret
|
||||||
#SECRET_SMTP_PASSWORD_VERSION=v1
|
#SECRET_SMTP_PASSWORD_VERSION=v1
|
||||||
|
|
||||||
SECRET_DB_PASSWORD_VERSION=v1
|
SECRET_DB_PASSWORD_VERSION=v1
|
||||||
|
|
||||||
|
# Postgres bootstrap superuser (the cluster's "install user"). Defaults to
|
||||||
|
# `postgres`, which matches fresh installs and bitnami-origin clusters. Only set
|
||||||
|
# this if you are upgrading a cluster that was bootstrapped with a different
|
||||||
|
# superuser (e.g. `discourse`) — a postgres major upgrade fails unless it matches.
|
||||||
|
#POSTGRES_USER=postgres
|
||||||
|
|||||||
74
README.md
74
README.md
@ -6,42 +6,70 @@ A platform for community discussion
|
|||||||
|
|
||||||
<!-- metadata -->
|
<!-- metadata -->
|
||||||
* **Category**: Apps
|
* **Category**: Apps
|
||||||
* **Status**:
|
* **Status**: 3, experimental
|
||||||
* **Image**: [`bitnami/discourse`](https://hub.docker.com/r/bitname/discourse)
|
* **Image**: [`discourse/discourse`](https://hub.docker.com/r/discourse/discourse), 4, upstream
|
||||||
* **Healthcheck**: yes
|
* **Healthcheck**: yes
|
||||||
* **Backups**: no
|
* **Backups**: yes
|
||||||
* **Email**: yes
|
* **Email**: yes
|
||||||
* **Tests**: no
|
* **Tests**: yes
|
||||||
* **SSO**: no
|
* **SSO**: no
|
||||||
<!-- endmetadata -->
|
<!-- endmetadata -->
|
||||||
|
|
||||||
|
> **Note**: this recipe runs the official, **experimental** `discourse/discourse`
|
||||||
|
> image. Upstream does not yet recommend it for production — see
|
||||||
|
> <https://meta.discourse.org/t/380646>. Use with care.
|
||||||
|
|
||||||
## Basic usage
|
## Basic usage
|
||||||
|
|
||||||
1. Set up Docker Swarm and [`abra`]
|
1. Set up Docker Swarm and [`abra`]
|
||||||
2. Deploy [`coop-cloud/traefik`]
|
2. Deploy [`coop-cloud/traefik`]
|
||||||
3. `abra app new discourse --secrets` (optionally with `--pass` if you'd like
|
3. `abra app new discourse --secrets`
|
||||||
to save secrets in `pass`)
|
4. `abra app config YOURAPPDOMAIN` — set `DOMAIN` and `DISCOURSE_DEVELOPER_EMAILS`
|
||||||
4. `abra app YOURAPPDOMAIN config` - be sure to change `$DOMAIN` to something that resolves to
|
5. `abra app deploy YOURAPPDOMAIN`
|
||||||
your Docker swarm box
|
6. Open the configured domain in your browser to finish set-up. The first account
|
||||||
5. `abra app YOURAPPDOMAIN deploy`
|
that registers with an address listed in `DISCOURSE_DEVELOPER_EMAILS` becomes
|
||||||
6. Open the configured domain in your browser to finish set-up
|
an admin.
|
||||||
|
|
||||||
[`abra`]: https://git.autonomic.zone/autonomic-cooperative/abra
|
[`abra`]: https://docs.coopcloud.tech/abra/
|
||||||
[`coop-cloud/traefik`]: https://git.autonomic.zone/coop-cloud/traefik
|
[`coop-cloud/traefik`]: https://git.coopcloud.tech/coop-cloud/traefik
|
||||||
|
|
||||||
## To add a new Admin user
|
The app serves plain HTTP on port 80; Traefik terminates TLS in front of it. The
|
||||||
|
image's built-in nginx/Let's Encrypt is disabled by the recipe (`install-ssl`
|
||||||
|
override) so it works behind the reverse proxy.
|
||||||
|
|
||||||
1. Login to the instance `abra app run APPNAME app sh`
|
## Add an admin user
|
||||||
2. `cd /opt/bitnami/discourse`
|
|
||||||
3. `RAILS_ENV=production bundle exec rake admin:create` and follow prompts.
|
|
||||||
|
|
||||||
## Install plugins
|
```
|
||||||
|
abra app run YOURAPPDOMAIN app discourse admin create
|
||||||
|
```
|
||||||
|
|
||||||
1. Login to instance `abra app run APPNAME app sh`
|
## Postgres major version upgrades
|
||||||
2. `cd /bitnami/discourse/plugins/`
|
|
||||||
3. `git clone plugingit` for example `https://github.com/discourse/discourse-openid-connect.git`
|
|
||||||
4. `abra app restart APPNAME app`
|
|
||||||
|
|
||||||
## Setup Notes
|
Handled automatically by the [`discourse/postgres`] image (pgvector + an
|
||||||
|
auto-upgrade layer). On deploy it finds an older cluster, installs the old
|
||||||
|
binaries and runs `pg_upgrade` into the new versioned data directory. No manual
|
||||||
|
dump/restore needed.
|
||||||
|
|
||||||
Until issue #1 is fixed, the default user is `user` and the default password is `bitnami123`
|
`pg_upgrade` must run as the old cluster's bootstrap superuser (its "install
|
||||||
|
user"). The recipe uses `POSTGRES_USER`, which defaults to `postgres` — the right
|
||||||
|
value for fresh installs and for clusters that came from the old bitnami recipe.
|
||||||
|
If your cluster was bootstrapped with a different superuser (e.g. `discourse`),
|
||||||
|
set `POSTGRES_USER` in the app `.env` before upgrading, otherwise `pg_upgrade`
|
||||||
|
will refuse with an install-user mismatch.
|
||||||
|
|
||||||
|
[`discourse/postgres`]: https://github.com/discourse/discourse-postgres
|
||||||
|
|
||||||
|
## Migrating from the previous (bitnami) recipe
|
||||||
|
|
||||||
|
The official image stores uploads under `/shared` rather than bitnami's
|
||||||
|
`/bitnami/discourse`. On first boot the recipe copies uploads + backups from the
|
||||||
|
old bitnami volume (mounted read-only at `/legacy`) into `/shared`, once,
|
||||||
|
idempotently. The Postgres database is reused as-is. After a successful migration
|
||||||
|
a later recipe version will drop the transitional `/legacy` mount.
|
||||||
|
|
||||||
|
If you are upgrading from the bitnami recipe, also remove the now-unused sidekiq
|
||||||
|
service that swarm leaves behind (sidekiq runs inside the app container now):
|
||||||
|
|
||||||
|
```
|
||||||
|
docker service rm YOURSTACK_sidekiq
|
||||||
|
```
|
||||||
|
|||||||
4
abra.sh
Normal file
4
abra.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export PG_BACKUP_VERSION=v4
|
||||||
|
export APP_ENTRYPOINT_VERSION=v2
|
||||||
|
export APP_INSTALL_SSL_VERSION=v1
|
||||||
|
export APP_MIGRATE_UPLOADS_VERSION=v1
|
||||||
11
app-install-ssl.sh
Executable file
11
app-install-ssl.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Overrides the official image's /etc/runit/1.d/install-ssl.
|
||||||
|
#
|
||||||
|
# The stock install-ssl always runs configure-ssl (and configure-letsencrypt),
|
||||||
|
# which empties the default `listen 80` nginx outlet and switches to `listen 443
|
||||||
|
# ssl` against a cert that does not exist here — nginx then crash-loops, or the
|
||||||
|
# image tries to obtain its own Let's Encrypt cert. Under Co-op Cloud, Traefik
|
||||||
|
# terminates TLS and proxies plain HTTP to port 80, so we skip the image's SSL
|
||||||
|
# setup entirely and let nginx keep its default HTTP-on-80 config.
|
||||||
|
echo "install-ssl overridden by recipe: serving plain HTTP on :80 behind Traefik"
|
||||||
|
exit 0
|
||||||
15
cc-app-entrypoint.sh
Executable file
15
cc-app-entrypoint.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Co-op Cloud wrapper around the official image's /sbin/boot.
|
||||||
|
# discourse/discourse reads passwords from the process env (pups/Ruby; it has no
|
||||||
|
# *_FILE support), so inject them from the docker secrets before booting.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -f /run/secrets/db_password ]; then
|
||||||
|
export DISCOURSE_DB_PASSWORD="$(cat /run/secrets/db_password)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f /run/secrets/smtp_password ]; then
|
||||||
|
export DISCOURSE_SMTP_PASSWORD="$(cat /run/secrets/smtp_password)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec /sbin/boot
|
||||||
@ -3,14 +3,8 @@ version: "3.8"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
environment:
|
# the wrapper entrypoint reads /run/secrets/smtp_password and exports
|
||||||
- DISCOURSE_SMTP_PASSWORD_FILE=/var/run/secrets/smtp_password
|
# DISCOURSE_SMTP_PASSWORD (the official image has no *_FILE support)
|
||||||
secrets:
|
|
||||||
- smtp_password
|
|
||||||
|
|
||||||
sidekiq:
|
|
||||||
environment:
|
|
||||||
- DISCOURSE_SMTP_PASSWORD_FILE=/var/run/secrets/smtp_password
|
|
||||||
secrets:
|
secrets:
|
||||||
- smtp_password
|
- smtp_password
|
||||||
|
|
||||||
|
|||||||
163
compose.yml
163
compose.yml
@ -3,99 +3,130 @@ version: "3.8"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: bitnami/discourse:2.8.9
|
image: discourse/discourse:3.5.3
|
||||||
networks:
|
networks:
|
||||||
- proxy
|
- proxy
|
||||||
- internal
|
- internal
|
||||||
# entrypoint: ['tail', '-f', '/dev/null']
|
# official image CMD is /sbin/boot; wrapper injects the DB password secret first
|
||||||
|
entrypoint: /usr/local/bin/cc-app-entrypoint.sh
|
||||||
environment:
|
environment:
|
||||||
- ALLOW_EMPTY_PASSWORD=yes
|
- DISCOURSE_HOSTNAME=${DOMAIN}
|
||||||
- DISCOURSE_HOST=${DOMAIN}
|
- DISCOURSE_DEVELOPER_EMAILS=${DISCOURSE_DEVELOPER_EMAILS}
|
||||||
- DISCOURSE_DATABASE_HOST=db
|
- DISCOURSE_DB_HOST=${STACK_NAME}_db
|
||||||
- DISCOURSE_DATABASE_USER=discourse
|
- DISCOURSE_DB_PORT=5432
|
||||||
- DISCOURSE_DATABASE_NAME=discourse
|
- DISCOURSE_DB_NAME=discourse
|
||||||
- DISCOURSE_DATABASE_PASSWORD_FILE=/run/secrets/db_password
|
- DISCOURSE_DB_USERNAME=discourse
|
||||||
- DISCOURSE_SMTP_HOST
|
- DISCOURSE_REDIS_HOST=${STACK_NAME}_redis
|
||||||
|
- DISCOURSE_REDIS_PORT=6379
|
||||||
|
- DISCOURSE_SMTP_ADDRESS
|
||||||
- DISCOURSE_SMTP_PORT
|
- DISCOURSE_SMTP_PORT
|
||||||
- DISCOURSE_SMTP_USER
|
- DISCOURSE_SMTP_USER_NAME
|
||||||
- DISCOURSE_SMTP_PROTOCOL
|
- DISCOURSE_SMTP_PASSWORD
|
||||||
- DISCOURSE_SMTP_AUTH
|
- DISCOURSE_SMTP_AUTHENTICATION
|
||||||
|
- DISCOURSE_SMTP_ENABLE_START_TLS
|
||||||
|
- DISCOURSE_NOTIFICATION_EMAIL
|
||||||
volumes:
|
volumes:
|
||||||
- 'discourse_data:/bitnami/discourse'
|
- 'discourse_shared:/shared'
|
||||||
|
# transition only: legacy bitnami volume, read-only, for one-time upload migration
|
||||||
|
- 'discourse_data:/legacy:ro'
|
||||||
secrets:
|
secrets:
|
||||||
- db_password
|
- db_password
|
||||||
|
configs:
|
||||||
|
- source: app_entrypoint
|
||||||
|
target: /usr/local/bin/cc-app-entrypoint.sh
|
||||||
|
mode: 0555
|
||||||
|
- source: app_install_ssl
|
||||||
|
target: /etc/runit/1.d/install-ssl
|
||||||
|
mode: 0555
|
||||||
|
- source: app_migrate_uploads
|
||||||
|
target: /etc/runit/1.d/02-migrate-bitnami-uploads
|
||||||
|
mode: 0555
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
- redis
|
- redis
|
||||||
deploy:
|
deploy:
|
||||||
update_config:
|
update_config:
|
||||||
failure_action: rollback
|
failure_action: rollback
|
||||||
order: start-first
|
order: stop-first
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=3000"
|
- "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=80"
|
||||||
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})"
|
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})"
|
||||||
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
|
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
|
||||||
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
|
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
|
||||||
## Redirect from EXTRA_DOMAINS to DOMAIN
|
- "coop-cloud.${STACK_NAME}.version=1.0.0+3.5.3"
|
||||||
#- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect"
|
healthcheck:
|
||||||
#- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true"
|
test: "curl -fsS http://localhost/srv/status || exit 1"
|
||||||
#- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}"
|
interval: 30s
|
||||||
- "coop-cloud.${STACK_NAME}.version=0.3.0+2.8.9"
|
timeout: 10s
|
||||||
# healthcheck:
|
retries: 6
|
||||||
# test: ["CMD", "curl", "-f", "http://localhost:3000"]
|
start_period: 25m
|
||||||
# interval: 30s
|
|
||||||
# timeout: 10s
|
|
||||||
# retries: 10
|
|
||||||
# start_period: 1m
|
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: postgres:13-alpine
|
# discourse/postgres = pgvector + discourse's postgres management layer, which
|
||||||
|
# auto-upgrades an older cluster in place on boot (pg_upgrade into the versioned
|
||||||
|
# PGDATA /var/lib/postgresql/${MAJOR}/docker); everything is driven by the env below.
|
||||||
|
image: discourse/postgres:pg18
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
secrets:
|
secrets:
|
||||||
- db_password
|
- db_password
|
||||||
volumes:
|
volumes:
|
||||||
- 'postgresql_data:/var/lib/postgresql/data'
|
# the image expects the whole cluster tree mounted here (not the data subdir);
|
||||||
|
# an existing pg17 cluster at the volume root is found and upgraded into /18/docker
|
||||||
|
- 'postgresql_data:/var/lib/postgresql'
|
||||||
|
configs:
|
||||||
|
- source: pg_backup
|
||||||
|
target: /pg_backup.sh
|
||||||
|
mode: 0555
|
||||||
|
entrypoint:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
if [ -f /run/secrets/db_password ]; then
|
||||||
|
DB_PASSWORD="$$(cat /run/secrets/db_password)"
|
||||||
|
export DB_PASSWORD POSTGRES_PASSWORD="$$DB_PASSWORD"
|
||||||
|
fi
|
||||||
|
exec run-postgres.sh postgres
|
||||||
environment:
|
environment:
|
||||||
|
# internal-only overlay network; keep all-trust so the app and the
|
||||||
|
# backup/restore hooks connect without juggling the superuser password
|
||||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||||
- POSTGRES_USER=discourse
|
|
||||||
- POSTGRES_DB=discourse
|
- POSTGRES_DB=discourse
|
||||||
- POSTGRES_PASSWORD_FILE=/run/secrets/db_password
|
- DB_USER=discourse
|
||||||
|
# pg_upgrade runs as this role and initdb's the new cluster with it; it must
|
||||||
|
# match the OLD cluster's bootstrap superuser (oid 10). The image default
|
||||||
|
# `postgres` matches fresh installs and bitnami-origin clusters. Override in
|
||||||
|
# the app .env (POSTGRES_USER=...) only for a cluster bootstrapped differently.
|
||||||
|
- POSTGRES_USER=${POSTGRES_USER:-postgres}
|
||||||
|
# pg18's initdb enables data checksums by default, but pg13-17 clusters here
|
||||||
|
# have them off and pg_upgrade requires a match -> initialise without them.
|
||||||
|
- POSTGRES_INITDB_ARGS=--no-data-checksums
|
||||||
|
healthcheck:
|
||||||
|
test: "pg_isready -U discourse -d discourse"
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 5
|
||||||
|
start_period: 15m
|
||||||
|
deploy:
|
||||||
|
labels:
|
||||||
|
backupbot.backup: "true"
|
||||||
|
backupbot.backup.pre-hook: "/pg_backup.sh backup"
|
||||||
|
backupbot.backup.volumes.postgresql_data.path: "backup.sql"
|
||||||
|
backupbot.restore.post-hook: "/pg_backup.sh restore"
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:7.0-alpine
|
image: redis:7.4-alpine
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
volumes:
|
volumes:
|
||||||
- 'redis_data:/data'
|
- 'redis_data:/data'
|
||||||
|
healthcheck:
|
||||||
sidekiq:
|
test: "redis-cli ping | grep -q PONG"
|
||||||
image: bitnami/discourse:2.8.9
|
interval: 30s
|
||||||
networks:
|
timeout: 5s
|
||||||
- internal
|
retries: 5
|
||||||
depends_on:
|
start_period: 30s
|
||||||
- discourse
|
|
||||||
volumes:
|
|
||||||
- 'sidekiq_data:/bitnami/discourse'
|
|
||||||
command: /opt/bitnami/scripts/discourse-sidekiq/run.sh
|
|
||||||
secrets:
|
|
||||||
- db_password
|
|
||||||
environment:
|
|
||||||
- ALLOW_EMPTY_PASSWORD=yes
|
|
||||||
- DISCOURSE_HOST=${DOMAIN}
|
|
||||||
- DISCOURSE_DATABASE_HOST=db
|
|
||||||
- DISCOURSE_DATABASE_PORT_NUMBER=5432
|
|
||||||
- DISCOURSE_DATABASE_USER=discourse
|
|
||||||
- DISCOURSE_DATABASE_NAME=discourse
|
|
||||||
- DISCOURSE_REDIS_HOST=redis
|
|
||||||
- DISCOURSE_REDIS_PORT_NUMBER=6379
|
|
||||||
- DISCOURSE_DATABASE_PASSWORD_FILE=/run/secrets/db_password
|
|
||||||
- DISCOURSE_SMTP_HOST
|
|
||||||
- DISCOURSE_SMTP_PORT
|
|
||||||
- DISCOURSE_SMTP_USER
|
|
||||||
- DISCOURSE_SMTP_PROTOCOL
|
|
||||||
- DISCOURSE_SMTP_AUTH
|
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
db_password:
|
db_password:
|
||||||
@ -105,10 +136,24 @@ secrets:
|
|||||||
volumes:
|
volumes:
|
||||||
postgresql_data:
|
postgresql_data:
|
||||||
redis_data:
|
redis_data:
|
||||||
|
discourse_shared:
|
||||||
discourse_data:
|
discourse_data:
|
||||||
sidekiq_data:
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
proxy:
|
proxy:
|
||||||
external: true
|
external: true
|
||||||
internal:
|
internal:
|
||||||
|
|
||||||
|
configs:
|
||||||
|
app_entrypoint:
|
||||||
|
name: ${STACK_NAME}_app_entrypoint_${APP_ENTRYPOINT_VERSION}
|
||||||
|
file: cc-app-entrypoint.sh
|
||||||
|
app_install_ssl:
|
||||||
|
name: ${STACK_NAME}_app_install_ssl_${APP_INSTALL_SSL_VERSION}
|
||||||
|
file: app-install-ssl.sh
|
||||||
|
app_migrate_uploads:
|
||||||
|
name: ${STACK_NAME}_app_migrate_uploads_${APP_MIGRATE_UPLOADS_VERSION}
|
||||||
|
file: migrate-uploads.sh
|
||||||
|
pg_backup:
|
||||||
|
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
|
||||||
|
file: pg_backup.sh
|
||||||
|
|||||||
24
migrate-uploads.sh
Executable file
24
migrate-uploads.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# One-time, idempotent, NON-destructive migration of uploads + backups from a
|
||||||
|
# legacy bitnami discourse volume into the official image's /shared.
|
||||||
|
#
|
||||||
|
# Runs on every boot as a runit 1.d hook but no-ops after the first success
|
||||||
|
# (sentinel) and when there is no legacy volume mounted (fresh installs). It only
|
||||||
|
# ever COPIES from the read-only /legacy mount, so an interruption just re-copies
|
||||||
|
# on the next boot — there is no move/delete to leave the data half-migrated.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SENTINEL=/shared/.bitnami-uploads-migrated
|
||||||
|
[ -e "$SENTINEL" ] && exit 0
|
||||||
|
|
||||||
|
if [ -d /legacy/public/uploads ]; then
|
||||||
|
echo "[migrate-uploads] copying bitnami uploads/backups -> /shared"
|
||||||
|
mkdir -p /shared/uploads /shared/backups
|
||||||
|
cp -a /legacy/public/uploads/. /shared/uploads/ 2>/dev/null || true
|
||||||
|
cp -a /legacy/public/backups/. /shared/backups/ 2>/dev/null || true
|
||||||
|
# discourse runs as uid 1000; the official boot also chowns /shared, but be explicit
|
||||||
|
chown -R discourse:discourse /shared/uploads /shared/backups 2>/dev/null || true
|
||||||
|
echo "[migrate-uploads] done"
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch "$SENTINEL"
|
||||||
47
pg_backup.sh
Executable file
47
pg_backup.sh
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Postgres backup/restore hook for the discourse `db` service (discourse/postgres image).
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# dump goes at the volume root so backupbot's backup.sql label finds it
|
||||||
|
BACKUP_FILE='/var/lib/postgresql/backup.sql'
|
||||||
|
DATADIR="${PGDATA:-/var/lib/postgresql/18/docker}"
|
||||||
|
DB_NAME="${POSTGRES_DB:-discourse}"
|
||||||
|
|
||||||
|
# bootstrap superuser for the dump/drop/recreate; same POSTGRES_USER the db service sets
|
||||||
|
SU="${POSTGRES_USER:-postgres}"
|
||||||
|
|
||||||
|
function backup {
|
||||||
|
pg_dump -U "$SU" "$DB_NAME" | gzip > "$BACKUP_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
function restore {
|
||||||
|
cd "$DATADIR"
|
||||||
|
|
||||||
|
# Block all non-local connections so the running discourse app + sidekiq cannot reconnect and
|
||||||
|
# interfere with the drop/recreate/reimport. Restored on exit.
|
||||||
|
restore_hba() {
|
||||||
|
cat pg_hba.conf.bak > pg_hba.conf
|
||||||
|
rm -f pg_hba.conf.bak
|
||||||
|
su postgres -c "pg_ctl -D '$DATADIR' reload"
|
||||||
|
}
|
||||||
|
cp pg_hba.conf pg_hba.conf.bak
|
||||||
|
echo 'local all all trust' > pg_hba.conf
|
||||||
|
su postgres -c "pg_ctl -D '$DATADIR' reload"
|
||||||
|
trap restore_hba EXIT INT TERM
|
||||||
|
|
||||||
|
# terminate any lingering local sessions before recreate
|
||||||
|
# see https://stackoverflow.com/questions/5108876/kill-a-postgresql-session-connection
|
||||||
|
psql -U "$SU" -d postgres -c \
|
||||||
|
"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='${DB_NAME}' AND pid<>pg_backend_pid();"
|
||||||
|
|
||||||
|
# drop database and then recreate it
|
||||||
|
psql -U "$SU" -d postgres -c "DROP DATABASE ${DB_NAME} WITH (FORCE);"
|
||||||
|
createdb -U "$SU" "$DB_NAME"
|
||||||
|
|
||||||
|
# reimport data
|
||||||
|
gunzip -c "$BACKUP_FILE" | psql -U "$SU" -d "$DB_NAME" -1 -v ON_ERROR_STOP=1 -f -
|
||||||
|
}
|
||||||
|
|
||||||
|
$@
|
||||||
19
release/1.0.0+3.5.3
Normal file
19
release/1.0.0+3.5.3
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
This release switches from the bitnami image to the official discourse/discourse
|
||||||
|
image. Some env vars need to be renamed for this migration; everything else
|
||||||
|
should happen automatically.
|
||||||
|
|
||||||
|
Rename these in your app's .env (the values carry over):
|
||||||
|
|
||||||
|
DISCOURSE_SMTP_HOST --> DISCOURSE_SMTP_ADDRESS
|
||||||
|
DISCOURSE_SMTP_USER --> DISCOURSE_SMTP_USER_NAME
|
||||||
|
DISCOURSE_SMTP_AUTH --> DISCOURSE_SMTP_AUTHENTICATION
|
||||||
|
DISCOURSE_SMTP_PROTOCOL --> DISCOURSE_SMTP_ENABLE_START_TLS (takes a boolean true/false, not the old tls/ssl value, so translate it rather than copying it straight across)
|
||||||
|
|
||||||
|
WARNING: if your deployment's database has an "install user" other than `postgres`
|
||||||
|
(some older deployments do), you must set the POSTGRES_USER env var in your .env
|
||||||
|
for this migration, otherwise the postgres upgrade aborts with an install-user
|
||||||
|
mismatch.
|
||||||
|
|
||||||
|
Check your old deployment's install user before upgrading (if this command returns postgres, then you do not need to set this env):
|
||||||
|
|
||||||
|
abra app run YOURAPPDOMAIN db -- psql -U discourse -tAc 'select rolname from pg_roles where oid = 10'
|
||||||
Reference in New Issue
Block a user