fix: use docker compose v2 (#4622)

* fix: use docker compose v2

* Using sudo tee.

* fix: correct postgres sed command

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>
Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>
This commit is contained in:
Tim Coombs 2024-05-07 19:41:40 +10:00 committed by GitHub
parent b152be7951
commit 522f974e30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,39 +4,39 @@ set -e
echo "Do not stop in the middle of this upgrade, wait until you see the message: Upgrade complete." echo "Do not stop in the middle of this upgrade, wait until you see the message: Upgrade complete."
echo "Stopping lemmy and all services..." echo "Stopping lemmy and all services..."
sudo docker-compose stop sudo docker compose stop
echo "Make sure postgres is started..." echo "Make sure postgres is started..."
sudo docker-compose up -d postgres sudo docker compose up -d postgres
echo "Waiting..." echo "Waiting..."
sleep 20s sleep 20s
echo "Exporting the Database to 15_16.dump.sql ..." echo "Exporting the Database to 15_16.dump.sql ..."
sudo docker-compose exec -T postgres pg_dumpall -c -U lemmy > 15_16_dump.sql sudo docker compose exec -T postgres pg_dumpall -c -U lemmy | sudo tee 15_16_dump.sql > /dev/null
echo "Done." echo "Done."
echo "Stopping postgres..." echo "Stopping postgres..."
sudo docker-compose stop postgres sudo docker compose stop postgres
echo "Waiting..." echo "Waiting..."
sleep 20s sleep 20s
echo "Removing the old postgres folder" echo "Removing the old postgres folder"
sudo rm -rf volumes/postgres sudo rm -rf volumes/postgres
echo "Updating docker-compose to use postgres version 16." echo "Updating docker compose to use postgres version 16."
sed -i "s/image: postgres:.*/image: postgres:16-alpine/" ./docker-compose.yml sudo sed -i "s/image: .*postgres:.*/image: docker.io/postgres:16-alpine/" ./docker-compose.yml
echo "Starting up new postgres..." echo "Starting up new postgres..."
sudo docker-compose up -d postgres sudo docker compose up -d postgres
echo "Waiting..." echo "Waiting..."
sleep 20s sleep 20s
echo "Importing the database...." echo "Importing the database...."
cat 15_16_dump.sql | sudo docker-compose exec -T postgres psql -U lemmy sudo cat 15_16_dump.sql | sudo docker compose exec -T postgres psql -U lemmy
echo "Done." echo "Done."
echo "Starting up lemmy..." echo "Starting up lemmy..."
sudo docker-compose up -d sudo docker compose up -d
echo "A copy of your old database is at 15_16.dump.sql . You can delete this file if the upgrade went smoothly." echo "A copy of your old database is at 15_16.dump.sql . You can delete this file if the upgrade went smoothly."
echo "Upgrade complete." echo "Upgrade complete."