This guide describes the process of migrating an existing production deployment (Systemd/Gunicorn) to the Docker-based setup.
- Backup: Ensure you have a full backup of your PostgreSQL database and media files.
- Docker: Ensure Docker and Docker Compose are installed on the server.
- Code: Pull the latest version of the repository.
Create a dump of your current database:
pg_dump -U separator separator > separator_backup.sqlReplace separator with your actual database user and name if different.
Ensure you have a copy of your media files (usually in separator/media).
Stop and disable the systemd services to prevent conflicts:
sudo systemctl stop separator-web separator-worker separator-beat asterx
sudo systemctl disable separator-web separator-worker separator-beat asterxUpdate your .env file. Add the following variable to enable the separate AsterX container:
ASTERX_SERVER=TrueStart the database container:
docker compose up -d dbCopy the backup into the container:
docker cp separator_backup.sql separator-db-1:/tmp/backup.sqlRestore the database:
docker exec -i separator-db-1 psql -U separator -d separator -f /tmp/backup.sqlEnsure your media files are located in separator/media/ within the project directory. Docker mounts the project directory to /app, so files in separator/media will be accessible.
Build and start the application:
docker compose up -d --buildCheck logs to ensure everything is running:
docker compose logs -fUpdate your host Nginx configuration to proxy requests to the Docker ports (8000 for Web, 9000 for AsterX).
Example configuration snippet:
upstream django_server {
server 127.0.0.1:8000;
}
upstream asterx_server {
server 127.0.0.1:9000;
}
server {
# ... existing config ...
location / {
proxy_pass http://django_server;
# ... proxy headers ...
}
location /ws/ {
proxy_pass http://asterx_server;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# Serve static and media files directly if mapped to host
location /static/ {
alias /path/to/project/staticfiles/;
}
location /media/ {
alias /path/to/project/separator/media/;
}
}Reload Nginx:
sudo nginx -t
sudo systemctl reload nginx