Trying to improve stg
This commit is contained in:
parent
e1a3d20332
commit
9e20068f8c
|
|
@ -1,4 +1,3 @@
|
||||||
# Staging/Production Dockerfile for Go server (no Air)
|
|
||||||
FROM golang:1.24-alpine AS builder
|
FROM golang:1.24-alpine AS builder
|
||||||
|
|
||||||
RUN apk add --no-cache git
|
RUN apk add --no-cache git
|
||||||
|
|
|
||||||
|
|
@ -73,27 +73,27 @@ ENVEOF
|
||||||
# Check containers
|
# Check containers
|
||||||
docker compose -f docker-compose.stg.yml ps
|
docker compose -f docker-compose.stg.yml ps
|
||||||
|
|
||||||
echo "Creating restore script for database from backups..."
|
# echo "Creating restore script for database from backups..."
|
||||||
# Create restore script for database from backups
|
# Create restore script for database from backups
|
||||||
cat > /home/cmc/restore_db_from_backup.sh <<'EOF'
|
# cat > /home/cmc/restore_db_from_backup.sh <<'EOF'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
LATEST_BACKUP=$(ls -t /backups/backup_*.sql.gz | head -n1)
|
# LATEST_BACKUP=$(ls -t /backups/backup_*.sql.gz | head -n1)
|
||||||
echo "Restoring database from latest backup: $LATEST_BACKUP"
|
# echo "Restoring database from latest backup: $LATEST_BACKUP"
|
||||||
if [ -f "$LATEST_BACKUP" ]; then
|
# if [ -f "$LATEST_BACKUP" ]; then
|
||||||
gunzip < "$LATEST_BACKUP" | mariadb -h 127.0.0.1 -u cmc -p"xVRQI&cA?7AU=hqJ!%au" cmc
|
# gunzip < "$LATEST_BACKUP" | mariadb -h 127.0.0.1 -u cmc -p"xVRQI&cA?7AU=hqJ!%au" cmc
|
||||||
echo "Database restore complete."
|
# echo "Database restore complete."
|
||||||
else
|
# else
|
||||||
echo "No backup file found in /backups. Skipping database restore."
|
# echo "No backup file found in /backups. Skipping database restore."
|
||||||
fi
|
# fi
|
||||||
EOF
|
# EOF
|
||||||
chmod +x /home/cmc/restore_db_from_backup.sh
|
# chmod +x /home/cmc/restore_db_from_backup.sh
|
||||||
|
|
||||||
echo "Creating sync script for staging directories..."
|
echo "Creating sync script for staging directories..."
|
||||||
# Create sync script for staging dirs
|
# Create sync script for staging dirs
|
||||||
cat > /home/cmc/sync_prod_to_staging.sh <<'EOF'
|
cat > /home/cmc/sync_prod_to_staging.sh <<'EOF'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
/home/cmc/restore_db_from_backup.sh
|
# /home/cmc/restore_db_from_backup.sh
|
||||||
|
|
||||||
# echo "Syncing PDF files..."
|
# echo "Syncing PDF files..."
|
||||||
# rsync -av --delete --omit-dir-times --no-perms --progress /mnt/vault/pdf/ /home/cmc/cmc-sales-staging/app/webroot/pdf/
|
# rsync -av --delete --omit-dir-times --no-perms --progress /mnt/vault/pdf/ /home/cmc/cmc-sales-staging/app/webroot/pdf/
|
||||||
# echo "Syncing attachments files..."
|
# echo "Syncing attachments files..."
|
||||||
|
|
@ -111,10 +111,10 @@ EOF
|
||||||
(crontab -l 2>/dev/null | grep -q '/home/cmc/sync_prod_to_staging.sh') || \
|
(crontab -l 2>/dev/null | grep -q '/home/cmc/sync_prod_to_staging.sh') || \
|
||||||
(crontab -l 2>/dev/null; echo '0 3 * * * /home/cmc/sync_prod_to_staging.sh') | crontab -
|
(crontab -l 2>/dev/null; echo '0 3 * * * /home/cmc/sync_prod_to_staging.sh') | crontab -
|
||||||
|
|
||||||
if [[ "$RUN_SYNC" == "true" ]]; then
|
# if [[ "$RUN_SYNC" == "true" ]]; then
|
||||||
echo "Running sync_prod_to_staging.sh now..."
|
# echo "Running sync_prod_to_staging.sh now..."
|
||||||
/home/cmc/sync_prod_to_staging.sh
|
# /home/cmc/sync_prod_to_staging.sh
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
echo "Deployment complete."
|
echo "Deployment complete."
|
||||||
ENDSSH
|
ENDSSH
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,14 @@ services:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile_stg
|
dockerfile: Dockerfile_stg
|
||||||
container_name: cmc-stg-php
|
container_name: cmc-stg-php
|
||||||
depends_on:
|
|
||||||
- db
|
|
||||||
environment:
|
environment:
|
||||||
MAIL_HOST: mailpit
|
MAIL_HOST: mailpit
|
||||||
MAIL_PORT: 1025
|
MAIL_PORT: 1025
|
||||||
|
DB_HOST: "172.17.0.1" # Updated to prod DB host
|
||||||
|
DB_PORT: 3306
|
||||||
|
DB_USER: cmc
|
||||||
|
DB_PASSWORD: xVRQI&cA?7AU=hqJ!%au
|
||||||
|
DB_NAME: cmc
|
||||||
volumes:
|
volumes:
|
||||||
- /var/www/cmc-sales/app/webroot:/var/www/cmc-sales/app/webroot:ro
|
- /var/www/cmc-sales/app/webroot:/var/www/cmc-sales/app/webroot:ro
|
||||||
- ./userpasswd:/etc/nginx/userpasswd:ro
|
- ./userpasswd:/etc/nginx/userpasswd:ro
|
||||||
|
|
@ -30,36 +33,18 @@ services:
|
||||||
- cmc-stg-network
|
- cmc-stg-network
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
db:
|
|
||||||
image: mariadb:latest
|
|
||||||
container_name: db
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: secureRootPassword
|
|
||||||
MYSQL_DATABASE: cmc
|
|
||||||
MYSQL_USER: cmc
|
|
||||||
MYSQL_PASSWORD: xVRQI&cA?7AU=hqJ!%au
|
|
||||||
volumes:
|
|
||||||
- stg_db_data:/var/lib/mysql
|
|
||||||
ports:
|
|
||||||
- "3307:3306" # Staging DB on different port
|
|
||||||
networks:
|
|
||||||
- cmc-stg-network
|
|
||||||
|
|
||||||
cmc-stg-go:
|
cmc-stg-go:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile.stg.go
|
dockerfile: Dockerfile.stg.go
|
||||||
container_name: cmc-stg-go
|
container_name: cmc-stg-go
|
||||||
environment:
|
environment:
|
||||||
DB_HOST: db
|
DB_HOST: "172.17.0.1" # Updated to prod DB host
|
||||||
DB_PORT: 3306
|
DB_PORT: 3306
|
||||||
DB_USER: cmc
|
DB_USER: cmc
|
||||||
DB_PASSWORD: xVRQI&cA?7AU=hqJ!%au
|
DB_PASSWORD: xVRQI&cA?7AU=hqJ!%au
|
||||||
DB_NAME: cmc
|
DB_NAME: cmc
|
||||||
PORT: 8082
|
PORT: 8082
|
||||||
depends_on:
|
|
||||||
db:
|
|
||||||
condition: service_started
|
|
||||||
ports:
|
ports:
|
||||||
- "8082:8082"
|
- "8082:8082"
|
||||||
volumes:
|
volumes:
|
||||||
|
|
@ -78,8 +63,5 @@ services:
|
||||||
- cmc-stg-network
|
- cmc-stg-network
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
|
||||||
stg_db_data:
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
cmc-stg-network:
|
cmc-stg-network:
|
||||||
|
|
|
||||||
|
|
@ -266,6 +266,10 @@ func main() {
|
||||||
// Checks quotes for reminders and expiry notices
|
// Checks quotes for reminders and expiry notices
|
||||||
quoteHandler.DailyQuoteExpirationCheck()
|
quoteHandler.DailyQuoteExpirationCheck()
|
||||||
})
|
})
|
||||||
|
s.Every(1).Minute().Do(func() {
|
||||||
|
// Checks quotes for reminders and expiry notices
|
||||||
|
quoteHandler.DailyQuoteExpirationCheck()
|
||||||
|
})
|
||||||
s.StartAsync()
|
s.StartAsync()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,6 @@ func (h *QuotesHandler) DailyQuoteExpirationCheck() {
|
||||||
reminderJobs := []quoteReminderJob{
|
reminderJobs := []quoteReminderJob{
|
||||||
{7, FirstReminder, "Reminder: Quote %s Expires Soon", "quotes/first_reminder.html"},
|
{7, FirstReminder, "Reminder: Quote %s Expires Soon", "quotes/first_reminder.html"},
|
||||||
{-7, SecondReminder, "Follow-Up: Quote %s Expired", "quotes/second_reminder.html"},
|
{-7, SecondReminder, "Follow-Up: Quote %s Expired", "quotes/second_reminder.html"},
|
||||||
{-44, ThirdReminder, "Final Reminder: Quote %s Closed", "quotes/final_reminder.html"}, // TODO: remove this its a tester
|
|
||||||
{-60, ThirdReminder, "Final Reminder: Quote %s Closed", "quotes/final_reminder.html"},
|
{-60, ThirdReminder, "Final Reminder: Quote %s Closed", "quotes/final_reminder.html"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
BIN
go-app/server
BIN
go-app/server
Binary file not shown.
Loading…
Reference in a new issue