2.2 KiB
2.2 KiB
Automated Deployment with Podman and rsync
This document describes how to automatically deploy the mold_cost_calculator application using Podman and rsync.
1. Build the Image Locally
podman build -t mold_cost_calculator:latest .
2. Save the Image as a Tarball
podman save -o mold_cost_calculator.tar mold_cost_calculator:latest
3. Transfer the Image to the Server Using rsync
Replace user@server1:/path/to/deploy/dir with your actual server username and path:
rsync -avz mold_cost_calculator.tar user@server1:/path/to/deploy/dir/
4. Load the Image on the Server
SSH into your server and run:
podman load -i /path/to/deploy/dir/mold_cost_calculator.tar
5. Stop and Remove the Old Container (if running)
podman stop mold_cost_calculator || true
podman rm mold_cost_calculator || true
6. Run the New Container
podman run -d --name mold_cost_calculator -p 5001:5001 --restart=always \
-v /path/to/instance:/app/instance \
-v /path/to/logs:/app/logs \
localhost/mold_cost_calculator:latest
- Adjust volume paths as needed.
7. (Optional) Automate with a Script
Create a script deploy.sh:
#!/bin/bash
set -e
# 1. Build image
podman build -t mold_cost_calculator:latest .
# 2. Save image
podman save -o mold_cost_calculator.tar mold_cost_calculator:latest
# 3. Rsync to server
rsync -avz mold_cost_calculator.tar user@server1:/path/to/deploy/dir/
# 4. SSH and deploy on server
ssh user@server1 <<'ENDSSH'
cd /path/to/deploy/dir/
podman load -i mold_cost_calculator.tar
podman stop mold_cost_calculator || true
podman rm mold_cost_calculator || true
podman run -d --name mold_cost_calculator -p 5001:5001 --restart=always \
-v /path/to/instance:/app/instance \
-v /path/to/logs:/app/logs \
localhost/mold_cost_calculator:latest
ENDSSH
- Make it executable:
chmod +x deploy.sh - Update all
/path/to/...anduser@server1as needed.
Notes
- Ensure Podman is installed on both local and server machines.
- Adjust volume paths and ports as needed for your environment.
- Nginx should be configured to reverse proxy to port 5001 on the server.
- For further automation, consider using CI/CD tools.