-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·26 lines (19 loc) · 910 Bytes
/
deploy.sh
File metadata and controls
executable file
·26 lines (19 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
# Stop script execution on the first error.
# If git pull fails due to conflicts, Docker will not build broken code.
set -e
echo "=== [1/4] Pulling updates from repository ==="
git pull origin main
echo "=== [2/4] Updating Nginx configuration ==="
# Copy config from repository to system directory
sudo cp infra/nginx/optifood.conf /etc/nginx/sites-available/default
# Strict syntax check. If the config has an error, the script stops here.
sudo nginx -t
sudo systemctl reload nginx
echo "=== [3/4] Building and starting infrastructure (Docker) ==="
# Uses Override Pattern. Prod config overrides unsafe settings from base.
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build
echo "=== [4/4] Cleaning up dangling images ==="
# Remove old dangling images to avoid filling up disk space on the server.
docker image prune -f
echo "=== OptiFood AI deploy complete ==="