Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
steps:

- name: Checkout Code Repository
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v6
with:
python-version: "3.12"
#cache: pip
Expand All @@ -45,7 +45,7 @@ jobs:
steps:

- name: Checkout Code Repository
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Build the Stack
run: docker compose -f local.yml build
Expand Down
2 changes: 1 addition & 1 deletion compose/production/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM postgres:15.3
FROM postgres:18.4

COPY ./compose/production/postgres/maintenance /usr/local/bin/maintenance
RUN chmod +x /usr/local/bin/maintenance/*
Expand Down
2 changes: 1 addition & 1 deletion compose/production/traefik/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM traefik:2.10.3
FROM traefik:v3.7.1
RUN mkdir -p /etc/traefik/acme \
&& touch /etc/traefik/acme/acme.json \
&& chmod 600 /etc/traefik/acme/acme.json
Expand Down
6 changes: 3 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
setuptools>=68.2.2,<82
whitenoise==6.6.0 # https://github.com/evansd/whitenoise
redis==5.0.1 # https://github.com/redis/redis-py
whitenoise==6.12.0 # https://github.com/evansd/whitenoise
redis==7.4.0 # https://github.com/redis/redis-py
celery==5.3.6 # pyup: < 6.0 # https://github.com/celery/celery
flower==2.0.1 # https://github.com/mher/flower
hiredis==2.2.3 # https://github.com/redis/hiredis-py
Expand All @@ -27,7 +27,7 @@ lxml==4.9.4 # https://github.com/lxml/lxml

# Kombu
# ------------------------------------------------------------------------------
kombu==5.4.2
kombu==5.6.2

# Tenacity
# ------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

-r base.txt

gevent==24.2.1 # http://www.gevent.org/
gevent==26.4.0 # http://www.gevent.org/
gunicorn==26.0.0
psycopg2-binary==2.9.9 # https://github.com/psycopg/psycopg2
sentry-sdk[django]==2.60.0
Expand Down
44 changes: 44 additions & 0 deletions scripts/postgres_pre_upgrade_backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
COMPOSE_FILE="${COMPOSE_FILE:-${ROOT_DIR}/local.yml}"
COMPOSE_SERVICE="${COMPOSE_SERVICE:-postgres}"
ARCHIVE_ROOT="${ARCHIVE_ROOT:-${ROOT_DIR}/../scms_data/markapi/postgres_backups_pre_upgrade}"
TIMESTAMP="$(date +'%Y_%m_%dT%H_%M_%S')"
ARCHIVE_DIR="${ARCHIVE_ROOT}/${TIMESTAMP}"

cd "${ROOT_DIR}"

if ! docker compose -f "${COMPOSE_FILE}" ps --status running "${COMPOSE_SERVICE}" 2>/dev/null | grep -q "${COMPOSE_SERVICE}"; then
echo "Serviço ${COMPOSE_SERVICE} não está em execução. Suba o stack: docker compose -f ${COMPOSE_FILE} up -d ${COMPOSE_SERVICE}"
exit 1
fi

echo "A criar backup lógico (pg_dump) no contentor ${COMPOSE_SERVICE}..."
docker compose -f "${COMPOSE_FILE}" exec -T "${COMPOSE_SERVICE}" backup

mkdir -p "${ARCHIVE_DIR}"
BACKUP_VOLUME="${BACKUP_VOLUME:-../scms_data/markapi/data_dev_backup}"

if [[ -d "${ROOT_DIR}/${BACKUP_VOLUME}" ]]; then
shopt -s nullglob
backups=("${ROOT_DIR}/${BACKUP_VOLUME}"/backup_*.sql.gz)
shopt -u nullglob
if [[ ${#backups[@]} -eq 0 ]]; then
echo "Nenhum ficheiro backup_*.sql.gz em ${ROOT_DIR}/${BACKUP_VOLUME}"
exit 1
fi
latest_backup="$(ls -t "${backups[@]}" | head -1)"
cp -a "${latest_backup}" "${ARCHIVE_DIR}/"
cp -a "${latest_backup}" "${ARCHIVE_ROOT}/latest_pre_upgrade.sql.gz"
echo "Cópia de segurança: ${ARCHIVE_DIR}/$(basename "${latest_backup}")"
echo "Atalho: ${ARCHIVE_ROOT}/latest_pre_upgrade.sql.gz"
else
echo "Volume de backups não encontrado (${ROOT_DIR}/${BACKUP_VOLUME}). O dump foi criado no contentor em /backups."
fi

echo "Concluído. Antes de subir Postgres 18, pare django/celery e siga docs/ops/postgres-upgrade-backup.md"
Loading