- Django
- Postgres
- Docker-compose
export existing local database :
docker exec -i pg_container_name /bin/bash -c "PGPASSWORD=pg_password pg_dump --username pg_username database_name" > /desired/path/on/your/machine/dump.sql
Stop existing database
docker exec -it leoclimb_db_1 psql -U paul -d postgres -c "SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'leoclimb';"
Drop current database
docker exec -it leoclimb_db_1 psql -U paul -d postgres -c "DROP DATABASE leoclimb;"
Import db
docker exec -it leoclimb-db bash
psql -U paul -d leoclimb -U paul -f db-export
python3 manage.py collectstatic
It will create static folder containing static app images and static admin css then in you ngnix conf render static folder
location /static {
autoindex on;
alias {path to manage.py}/static;
}
docker-compose up -d --build