41 lines
1.3 KiB
Plaintext
Executable File
41 lines
1.3 KiB
Plaintext
Executable File
#\!/bin/bash
|
|
|
|
# Post-receive hook for coppertone.tech deployment
|
|
# Triggered when code is pushed to this bare repo
|
|
|
|
set -e
|
|
|
|
DEPLOY_DIR="/docker/web-hosts/domains/coppertone.tech-deploy"
|
|
REPO_DIR="/docker/web-hosts/domains/coppertone.tech"
|
|
LOG_FILE="/docker/web-hosts/domains/coppertone.tech-deploy.log"
|
|
|
|
echo "=== Deployment started at $(date) ===" | tee -a "$LOG_FILE"
|
|
|
|
# Create deploy directory if it doesn't exist
|
|
mkdir -p "$DEPLOY_DIR"
|
|
|
|
# Checkout the latest code from bare repo
|
|
echo "Checking out latest code..." | tee -a "$LOG_FILE"
|
|
cd "$REPO_DIR"
|
|
GIT_WORK_TREE="$DEPLOY_DIR" GIT_DIR="$REPO_DIR" git checkout -f main 2>&1 | tee -a "$LOG_FILE"
|
|
|
|
cd "$DEPLOY_DIR"
|
|
|
|
# Build new containers
|
|
echo "Building containers..." | tee -a "$LOG_FILE"
|
|
podman-compose -f podman-compose.yml build 2>&1 | tee -a "$LOG_FILE"
|
|
|
|
# Stop old containers
|
|
echo "Stopping old containers..." | tee -a "$LOG_FILE"
|
|
podman-compose -f podman-compose.yml down 2>&1 | tee -a "$LOG_FILE"
|
|
|
|
# Start new containers
|
|
echo "Starting new containers..." | tee -a "$LOG_FILE"
|
|
podman-compose -f podman-compose.yml up -d 2>&1 | tee -a "$LOG_FILE"
|
|
|
|
# Reload nginx
|
|
echo "Reloading nginx..." | tee -a "$LOG_FILE"
|
|
/docker/www/scripts/nginx-reload.sh 2>&1 | tee -a "$LOG_FILE"
|
|
|
|
echo "=== Deployment completed at $(date) ===" | tee -a "$LOG_FILE"
|