From 6139ed45cdbe9cc6d9a86da85732cd86b96b8c91 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 19 Sep 2024 20:33:42 +0530 Subject: [PATCH 1/2] Revert "Remove postgres dep not needed in production" This reverts commit e695f2eccbef739ec63655378eab01c28f5d600f. --- infra/copycat-db/Dockerfile | 11 +++++++++++ infra/copycat-db/src/backup.sh | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/infra/copycat-db/Dockerfile b/infra/copycat-db/Dockerfile index 9ecb2c37a3..c22b50c070 100644 --- a/infra/copycat-db/Dockerfile +++ b/infra/copycat-db/Dockerfile @@ -3,6 +3,17 @@ FROM ubuntu:latest RUN apt-get update && apt-get install -y curl gnupg RUN apt-get install -y tini +# Install pg_dump (via Postgres client) +# https://www.postgresql.org/download/linux/ubuntu/ +# +# We don't need it for production backups, but this is useful for local testing. +RUN \ + apt-get install -y lsb-release && \ + sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \ + curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \ + apt-get update && \ + apt-get -y install postgresql-client-12 + # Install SCW CLI # Latest release: https://github.com/scaleway/scaleway-cli/releases/latest RUN \ diff --git a/infra/copycat-db/src/backup.sh b/infra/copycat-db/src/backup.sh index 1dcebf39dc..f197f4b0f0 100755 --- a/infra/copycat-db/src/backup.sh +++ b/infra/copycat-db/src/backup.sh @@ -18,9 +18,10 @@ EXPIRY="$(date -Iseconds --utc --date "@$EXPIRYS")" if test -z "$SCW_RDB_INSTANCE_ID" then - # A required SCW related environment variable hasn't been specified. - echo "Missing SCW_RDB_INSTANCE_ID" - exit 1 + # A required SCW related environment variable hasn't been specified. This is + # expected when running the script locally for testing. Fallback to using + # pg_dump for creating the backup. + pg_dump -Fc ente_db > $BACKUP_FILE else # We need to export a backup first after creating it, before it can be # downloaded. From e6d7d2298c18d56e726e088f03d5e66795dc6d59 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 19 Sep 2024 20:38:27 +0530 Subject: [PATCH 2/2] Update --- infra/copycat-db/Dockerfile | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/infra/copycat-db/Dockerfile b/infra/copycat-db/Dockerfile index c22b50c070..9d58c09fa8 100644 --- a/infra/copycat-db/Dockerfile +++ b/infra/copycat-db/Dockerfile @@ -3,16 +3,11 @@ FROM ubuntu:latest RUN apt-get update && apt-get install -y curl gnupg RUN apt-get install -y tini -# Install pg_dump (via Postgres client) +# Install Postgres client (needed for restores, and for local testing) # https://www.postgresql.org/download/linux/ubuntu/ # -# We don't need it for production backups, but this is useful for local testing. -RUN \ - apt-get install -y lsb-release && \ - sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \ - curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \ - apt-get update && \ - apt-get -y install postgresql-client-12 +# We don't have specific dependencies on Postgres, so just use the latest. +RUN apt-get update && apt-get -y install postgresql-client # Install SCW CLI # Latest release: https://github.com/scaleway/scaleway-cli/releases/latest