Open a new discussion regarding why it takes so long on Bionic? I think it’d be beneficial. I’d like more people to push towards using PostgreSQL 12 since there are a lot of internal improvements. It doesn’t seem like a systemctl issue since Redis starts up quickly for me…
Yes this one works @Andrew-Chen-Wang but only on port 5433 I believe. I’ve been experimenting with environment variables a bit and didn’t notice any impact. I’ve got it working like this:
I encountered the same problem, but with the default image for Python 3.7. Solved with:
- sudo cp /etc/postgresql/10/main/pg_hba.conf /etc/postgresql/12/main/pg_hba.conf
- sudo pg_ctlcluster 12 main restart
- sh -c 'until pg_isready -p 5433; do echo "Waiting for the DB to be up..."; sleep 2; done'
- psql -U postgres -p 5433 -c "CREATE USER testuser WITH PASSWORD 'secret' LOGIN;"
- psql -U postgres -p 5433 -c "CREATE DATABASE grammarquiz OWNER testuser;"
- psql -U testuser -p 5433 -f scripts/populate_db/schema.sql grammarquiz
- psql -U testuser -p 5433 -q -f tests/database_content.sql grammarquiz
I need to use pg_isready because restarting the database doesn’t immediately leave it in an usable state so I cannot populate it with test data immediately.