diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcac553..8d919df 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/compose/production/postgres/Dockerfile b/compose/production/postgres/Dockerfile index aec0f7f..8b3ebd3 100755 --- a/compose/production/postgres/Dockerfile +++ b/compose/production/postgres/Dockerfile @@ -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/* diff --git a/compose/production/traefik/Dockerfile b/compose/production/traefik/Dockerfile index bdedff7..1becd44 100755 --- a/compose/production/traefik/Dockerfile +++ b/compose/production/traefik/Dockerfile @@ -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 diff --git a/requirements/base.txt b/requirements/base.txt index f48d0f1..2afc24b 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -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 @@ -27,7 +27,7 @@ lxml==4.9.4 # https://github.com/lxml/lxml # Kombu # ------------------------------------------------------------------------------ -kombu==5.4.2 +kombu==5.6.2 # Tenacity # ------------------------------------------------------------------------------ diff --git a/requirements/production.txt b/requirements/production.txt index a034216..a4042c1 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -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 diff --git a/scripts/postgres_pre_upgrade_backup.sh b/scripts/postgres_pre_upgrade_backup.sh new file mode 100755 index 0000000..fa6b158 --- /dev/null +++ b/scripts/postgres_pre_upgrade_backup.sh @@ -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"