Docker tasks¶
Update applications¶
Change to the application’s directory, replacing APP
:
cd /data/deploy/APP
Pull new images and start new containers:
docker compose pull
docker compose up -d
Migrate the database, for example:
docker compose run --rm --name my-app-migrate cron python manage.py migrate
One-time setup
Create a superuser, if applicable:
docker compose run --rm --name my-app-superuser cron python manage.py createsuperuser
Revert images¶
Find the SHA of the previous image:
docker image ls --digests
If the previous image has been pruned, visit the package’s page, like kingfisher-process-django.
Change the image in the Docker Compose file from
myproject:latest
tomyproject@sha256:0ed5d59...
.Start new containers:
docker compose pull docker compose up -d
Load data¶
For example:
psql -U pelican_backend -h localhost -c "\copy exchange_rates (valid_on, rates, created, modified) from 'exchange_rates.csv';" pelican_backend
Check that the ID sequence is correct:
SELECT MAX(id) FROM exchange_rates;
SELECT nextval('exchange_rates_id_seq');
The second value should be higher than the first. If not:
SELECT setval('exchange_rates_id_seq', COALESCE((SELECT MAX(id) + 1 FROM exchange_rates), 1), false);