Skip to content

Commit

Permalink
feat: switch from PostgreSQL 11 to PostgreSQL 16
Browse files Browse the repository at this point in the history
and use `robotoff` DB instead of `postgres`
  • Loading branch information
raphael0202 committed Jul 30, 2024
1 parent a372eda commit 7cdb0d2
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ELASTIC_PASSWORD=elastic

# Postgres
POSTGRES_HOST=postgres
POSTGRES_DB=postgres
POSTGRES_DB=robotoff
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
# Expose postgres on localhost for dev
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/container-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
# We use local PostgreSQL instance with `robotoff_default` network,
# so that there is no possibility of conflict with PO PostgreSQL instance.
echo "POSTGRES_HOST=postgres.robotoff_default" >> .env
echo "POSTGRES_DB=postgres" >> .env
echo "POSTGRES_DB=robotoff" >> .env
echo "POSTGRES_USER=postgres" >> .env
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> .env
echo "MONGO_URI=${{ env.MONGO_URI }}" >> .env
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,8 @@ pytest: guard-args
# Create all external volumes needed for production. Using external volumes is useful to prevent data loss (as they are not deleted when performing docker down -v)
create_external_volumes:
@echo "🥫 Creating external volumes (production only) …"
docker volume create api-dataset
docker volume create postgres-data
docker volume create es-data
docker volume create robotoff_postgres-data
docker volume create robotoff_es-data
# This is an NFS mount from robotoff backup ZFS dataset.
# Two important notes:
# - we use `nolock` as there shouldn't be any concurrent writes on the same file, and `soft` to prevent the docker container from freezing if the NFS
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ services:

postgres:
restart: $RESTART_POLICY
image: postgres:11.2-alpine
image: postgres:16.3-alpine
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
Expand Down Expand Up @@ -167,6 +167,7 @@ services:

volumes:
postgres-data:
name: ${COMPOSE_PROJECT_NAME:-robotoff}_postgres-data
backup:
name: ${COMPOSE_PROJECT_NAME:-robotoff}_backup
es-data:
Expand Down
1 change: 1 addition & 0 deletions docker/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ volumes:

postgres-data:
external: true
name: ${COMPOSE_PROJECT_NAME:-robotoff}_postgres-data
es-data:
external: true
name: ${COMPOSE_PROJECT_NAME:-robotoff}_es-data
Expand Down
2 changes: 1 addition & 1 deletion robotoff/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def event_api() -> str:
# Credentials for the Robotoff insights database

POSTGRES_HOST = os.environ.get("POSTGRES_HOST", "localhost")
POSTGRES_DB = os.environ.get("POSTGRES_DB", "postgres")
POSTGRES_DB = os.environ.get("POSTGRES_DB", "robotoff")
POSTGRES_USER = os.environ.get("POSTGRES_USER", "postgres")
POSTGRES_PASSWORD = os.environ.get("POSTGRES_PASSWORD", "postgres")

Expand Down
2 changes: 1 addition & 1 deletion scripts/backup_postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ mkdir -p $BASE_DIR
# We backup the two schemas in distinct backups, because the embedding schema is huge
# Save the backup in progress in a temporary file so that the latest dump file is always valid
# Wait 10s max for the lock to be released (avoid concurrent dump)
pg_dump --lock-wait-timeout=10000 -F c -U postgres postgres -f $BASE_DIR/robotoff_postgres.dump.tmp
pg_dump --lock-wait-timeout=10000 -F c -U postgres robotoff -f $BASE_DIR/robotoff_postgres.dump.tmp
mv $BASE_DIR/robotoff_postgres.dump.tmp $BASE_DIR/robotoff_postgres.dump
echo "$(date -u '+%Y-%m-%d %H:%M:%S') :: back-up completed"

0 comments on commit 7cdb0d2

Please sign in to comment.