Compare commits
1 Commits
ci/pg-rest
...
1.2.3+9.5.
| Author | SHA1 | Date | |
|---|---|---|---|
| 95aab820b1 |
@ -45,7 +45,7 @@ steps:
|
|||||||
from_secret: drone_abra-bot_token
|
from_secret: drone_abra-bot_token
|
||||||
fork: true
|
fork: true
|
||||||
repositories:
|
repositories:
|
||||||
- toolshed/auto-recipes-catalogue-json
|
- coop-cloud/auto-recipes-catalogue-json
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event: tag
|
event: tag
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
TYPE=mattermost-lts
|
TYPE=mattermost
|
||||||
|
|
||||||
# Domain of service
|
# Domain of service
|
||||||
DOMAIN=mattermost.example.com
|
DOMAIN=mattermost.example.com
|
||||||
|
|||||||
5
abra.sh
5
abra.sh
@ -1,4 +1 @@
|
|||||||
export ABRA_MATTERMOST_ENTRYPOINT_VERSION=v2
|
export ENTRYPOINT_VERSION=v1
|
||||||
export BUSYBOX_VERSION=v1
|
|
||||||
|
|
||||||
export PG_BACKUP_VERSION=v1
|
|
||||||
|
|||||||
25
compose.yml
25
compose.yml
@ -2,7 +2,7 @@ version: "3.8"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: mattermost/mattermost-team-edition:10.11.18
|
image: mattermost/mattermost-team-edition:9.5.9
|
||||||
environment:
|
environment:
|
||||||
- TZ
|
- TZ
|
||||||
- MM_SQLSETTINGS_DRIVERNAME=postgres
|
- MM_SQLSETTINGS_DRIVERNAME=postgres
|
||||||
@ -28,16 +28,13 @@ services:
|
|||||||
- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect"
|
- "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.SSLForceHost=true"
|
||||||
- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}"
|
- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}"
|
||||||
- "coop-cloud.${STACK_NAME}.version=2.1.10+10.11.18"
|
- "coop-cloud.${STACK_NAME}.version=1.2.3+9.5.9"
|
||||||
- "backupbot.backup=true"
|
- "backupbot.backup=true"
|
||||||
- "backupbot.backup.path=/mattermost,/etc/ssl"
|
- "backupbot.backup.path=/mattermost,/etc/ssl"
|
||||||
configs:
|
configs:
|
||||||
- source: abra_mattermost_entrypoint
|
- source: abra_mattermost_entrypoint
|
||||||
target: /abra-mattermost-entrypoint.sh
|
target: /abra-mattermost-entrypoint.sh
|
||||||
mode: 0555
|
mode: 0555
|
||||||
- source: busybox
|
|
||||||
target: /bin/busybox
|
|
||||||
mode: 0555
|
|
||||||
secrets:
|
secrets:
|
||||||
- postgres_password
|
- postgres_password
|
||||||
entrypoint: /abra-mattermost-entrypoint.sh
|
entrypoint: /abra-mattermost-entrypoint.sh
|
||||||
@ -58,13 +55,9 @@ services:
|
|||||||
deploy:
|
deploy:
|
||||||
labels:
|
labels:
|
||||||
backupbot.backup: "true"
|
backupbot.backup: "true"
|
||||||
backupbot.backup.pre-hook: "/pg_backup.sh backup"
|
backupbot.backup.pre-hook: "PGPASSWORD=$$(cat $${POSTGRES_PASSWORD_FILE}) pg_dump -U $${POSTGRES_USER} $${POSTGRES_DB} > /var/lib/postgresql/data/postgres-backup.sql"
|
||||||
backupbot.backup.volumes.postgres_data.path: "backup.sql"
|
backupbot.backup.post-hook: "rm -rf /var/lib/postgresql/data/postgres-backup.sql"
|
||||||
backupbot.restore.post-hook: "/pg_backup.sh restore"
|
backupbot.backup.path: "/var/lib/postgresql/data/"
|
||||||
configs:
|
|
||||||
- source: pg_backup
|
|
||||||
target: /pg_backup.sh
|
|
||||||
mode: 0555
|
|
||||||
|
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
@ -73,15 +66,9 @@ secrets:
|
|||||||
name: ${STACK_NAME}_postgres_password_${SECRET_POSTGRES_PASSWORD_VERSION}
|
name: ${STACK_NAME}_postgres_password_${SECRET_POSTGRES_PASSWORD_VERSION}
|
||||||
|
|
||||||
configs:
|
configs:
|
||||||
pg_backup:
|
|
||||||
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
|
|
||||||
file: pg_backup.sh
|
|
||||||
abra_mattermost_entrypoint:
|
abra_mattermost_entrypoint:
|
||||||
name: ${STACK_NAME}_entrypoint_${ABRA_MATTERMOST_ENTRYPOINT_VERSION}
|
name: ${STACK_NAME}_entrypoint_${ENTRYPOINT_VERSION}
|
||||||
file: ./entrypoint.sh
|
file: ./entrypoint.sh
|
||||||
busybox:
|
|
||||||
name: ${STACK_NAME}_busybox_${BUSYBOX_VERSION}
|
|
||||||
file: ./busybox
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
proxy:
|
proxy:
|
||||||
|
|||||||
6
entrypoint.sh
Executable file → Normal file
6
entrypoint.sh
Executable file → Normal file
@ -1,7 +1,7 @@
|
|||||||
#!/bin/busybox sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
if test -f "/run/secrets/postgres_password"; then
|
if test -f "/run/secrets/postgres_password"; then
|
||||||
pwd=`/bin/busybox cat /run/secrets/postgres_password`
|
pwd=`cat /run/secrets/postgres_password`
|
||||||
if [ -z $pwd ]; then
|
if [ -z $pwd ]; then
|
||||||
echo >&2 "error: /run/secrets/postgres_password is empty"
|
echo >&2 "error: /run/secrets/postgres_password is empty"
|
||||||
exit 1
|
exit 1
|
||||||
@ -16,4 +16,4 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# https://github.com/mattermost/mattermost-server/blob/master/build/Dockerfile
|
# https://github.com/mattermost/mattermost-server/blob/master/build/Dockerfile
|
||||||
/mattermost/bin/mattermost
|
/entrypoint.sh "mattermost"
|
||||||
|
|||||||
32
pg_backup.sh
32
pg_backup.sh
@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Postgres backup/restore hook for the `postgres` service. Invoked by backupbot-two via:
|
|
||||||
# backupbot.backup.pre-hook = "/pg_backup.sh backup"
|
|
||||||
# backupbot.backup.volumes.postgres_data.path = "backup.sql"
|
|
||||||
# backupbot.restore.post-hook = "/pg_backup.sh restore"
|
|
||||||
# Backup dumps the DB to backup.sql (gzip) inside the postgres volume; backupbot archives it.
|
|
||||||
# Restore reimports it. The mattermost app keeps TCP connections open to the DB, so restore must
|
|
||||||
# terminate them and FORCE-drop before recreating, then reimport the dump deterministically — the
|
|
||||||
# previous recipe shipped no restore hook (file-level PGDATA restore did not reload into the running
|
|
||||||
# postgres), so a restored backup silently kept the live (un-restored) state.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
BACKUP_FILE='/var/lib/postgresql/data/backup.sql'
|
|
||||||
export PGPASSWORD=$(cat "${POSTGRES_PASSWORD_FILE:-/run/secrets/postgres_password}")
|
|
||||||
DB_USER="${POSTGRES_USER:-mattermost}"
|
|
||||||
DB_NAME="${POSTGRES_DB:-mattermost}"
|
|
||||||
|
|
||||||
function backup {
|
|
||||||
pg_dump -U "$DB_USER" "$DB_NAME" | gzip > "$BACKUP_FILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
function restore {
|
|
||||||
psql -U "$DB_USER" -d postgres -c \
|
|
||||||
"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='${DB_NAME}' AND pid<>pg_backend_pid();"
|
|
||||||
psql -U "$DB_USER" -d postgres -c "DROP DATABASE ${DB_NAME} WITH (FORCE);"
|
|
||||||
createdb -U "$DB_USER" "$DB_NAME"
|
|
||||||
gunzip -c "$BACKUP_FILE" | psql -U "$DB_USER" -d "$DB_NAME" -1 -v ON_ERROR_STOP=1 -f -
|
|
||||||
}
|
|
||||||
|
|
||||||
$@
|
|
||||||
@ -1 +0,0 @@
|
|||||||
hotfix: rollback to last functional version
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Mattermost Platform Extended Support Release 10.5.8 contains a high severity level security fix.
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
the docker containers in 10.11 branch don't contain any unix programs. That
|
|
||||||
means there's no sh or bash, no cat etc etc. We need to have a shell to run
|
|
||||||
our entrypoint and export the postgres URL as an env variable. To overcome
|
|
||||||
this we insert a busybox binary as a config into the container. There's no
|
|
||||||
action required on the side of the operator but it's important to note.
|
|
||||||
Reference in New Issue
Block a user