fix: staging packages, image URL and database scripts
All checks were successful
Deploy to Staging / Build Images (push) Successful in 3m28s
Deploy to Staging / Deploy to Staging (push) Successful in 27s
Deploy to Staging / Verify Staging (push) Successful in 5s
Deploy to Staging / Notify Staging Ready (push) Successful in 5s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
All checks were successful
Deploy to Staging / Build Images (push) Successful in 3m28s
Deploy to Staging / Deploy to Staging (push) Successful in 27s
Deploy to Staging / Verify Staging (push) Successful in 5s
Deploy to Staging / Notify Staging Ready (push) Successful in 5s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
This commit is contained in:
@@ -9,14 +9,18 @@ set -e
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
CONTAINER_NAME="mvp-postgres"
|
||||
DATABASE_NAME="motovaultpro"
|
||||
|
||||
# Environment-based container names
|
||||
CONTAINER_NAME="" # Will be set based on environment selection
|
||||
ENVIRONMENT="" # production or staging
|
||||
|
||||
# Default values
|
||||
BACKUP_EXISTING=true
|
||||
DROP_EXISTING=false
|
||||
@@ -36,6 +40,69 @@ print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
print_env() {
|
||||
echo -e "${BLUE}[ENV]${NC} $1"
|
||||
}
|
||||
|
||||
# Function to select environment
|
||||
select_environment() {
|
||||
if [ -n "$ENVIRONMENT" ]; then
|
||||
# Environment already set via command line
|
||||
return
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE} MotoVaultPro Database Import${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo ""
|
||||
echo "Select environment to import to:"
|
||||
echo ""
|
||||
echo " 1) Production (mvp-postgres)"
|
||||
echo " 2) Staging (mvp-postgres-staging)"
|
||||
echo ""
|
||||
read -p "Enter choice [1-2]: " ENV_CHOICE
|
||||
|
||||
case $ENV_CHOICE in
|
||||
1)
|
||||
ENVIRONMENT="production"
|
||||
CONTAINER_NAME="mvp-postgres"
|
||||
;;
|
||||
2)
|
||||
ENVIRONMENT="staging"
|
||||
CONTAINER_NAME="mvp-postgres-staging"
|
||||
;;
|
||||
*)
|
||||
print_error "Invalid choice. Please enter 1 or 2."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo ""
|
||||
print_env "Selected environment: ${ENVIRONMENT}"
|
||||
print_env "Container: ${CONTAINER_NAME}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Function to set container name based on environment
|
||||
set_container_from_environment() {
|
||||
case $ENVIRONMENT in
|
||||
production|prod)
|
||||
ENVIRONMENT="production"
|
||||
CONTAINER_NAME="mvp-postgres"
|
||||
;;
|
||||
staging|stage)
|
||||
ENVIRONMENT="staging"
|
||||
CONTAINER_NAME="mvp-postgres-staging"
|
||||
;;
|
||||
*)
|
||||
print_error "Invalid environment: $ENVIRONMENT"
|
||||
print_error "Valid options: production, staging"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to show usage
|
||||
show_usage() {
|
||||
cat << EOF
|
||||
@@ -45,7 +112,8 @@ Usage: $0 [options] <export-file>
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message
|
||||
-c, --container NAME Container name (default: mvp-postgres)
|
||||
-e, --env ENV Environment: production or staging (prompts if not specified)
|
||||
-c, --container NAME Override container name (ignores environment selection)
|
||||
-d, --database NAME Database name (default: motovaultpro)
|
||||
--create-db Create database if it doesn't exist
|
||||
--drop-existing Drop existing database before import (DANGER!)
|
||||
@@ -53,15 +121,25 @@ Options:
|
||||
--force Skip confirmation prompts
|
||||
-f, --format FORMAT Import format: sql, custom, directory (auto-detected if not specified)
|
||||
|
||||
Environments:
|
||||
production (prod) Uses container: mvp-postgres
|
||||
staging (stage) Uses container: mvp-postgres-staging
|
||||
|
||||
Examples:
|
||||
# Import a standard SQL dump
|
||||
$0 database-exports/motovaultpro_export_20250101_120000.sql.gz
|
||||
# Interactive environment selection
|
||||
$0 database-exports/backup.sql.gz
|
||||
|
||||
# Import with database recreation
|
||||
$0 --drop-existing --create-db backup.sql
|
||||
# Import to production
|
||||
$0 --env production database-exports/backup.sql.gz
|
||||
|
||||
# Import custom format
|
||||
$0 --format custom backup.dump
|
||||
# Import to staging
|
||||
$0 --env staging database-exports/backup.sql.gz
|
||||
|
||||
# Import with database recreation to staging
|
||||
$0 -e staging --drop-existing --create-db backup.sql
|
||||
|
||||
# Import custom format to production
|
||||
$0 --env prod --format custom backup.dump
|
||||
|
||||
Safety Features:
|
||||
- Creates backup of existing database by default
|
||||
@@ -74,13 +152,19 @@ EOF
|
||||
}
|
||||
|
||||
# Parse command line arguments
|
||||
CONTAINER_OVERRIDE=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_usage
|
||||
;;
|
||||
-e|--env)
|
||||
ENVIRONMENT="$2"
|
||||
shift 2
|
||||
;;
|
||||
-c|--container)
|
||||
CONTAINER_NAME="$2"
|
||||
CONTAINER_OVERRIDE="$2"
|
||||
shift 2
|
||||
;;
|
||||
-d|--database)
|
||||
@@ -129,6 +213,20 @@ if [ ! -e "$IMPORT_FILE" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Handle environment selection
|
||||
if [ -n "$CONTAINER_OVERRIDE" ]; then
|
||||
# Container explicitly specified, use it directly
|
||||
CONTAINER_NAME="$CONTAINER_OVERRIDE"
|
||||
ENVIRONMENT="custom"
|
||||
print_info "Using custom container: $CONTAINER_NAME"
|
||||
elif [ -n "$ENVIRONMENT" ]; then
|
||||
# Environment specified via command line
|
||||
set_container_from_environment
|
||||
else
|
||||
# No environment specified, prompt user
|
||||
select_environment
|
||||
fi
|
||||
|
||||
# Auto-detect format if not specified
|
||||
if [ -z "$IMPORT_FORMAT" ]; then
|
||||
if [[ "$IMPORT_FILE" == *.sql.gz ]]; then
|
||||
@@ -205,6 +303,8 @@ fi
|
||||
|
||||
# Import based on format
|
||||
print_info "Starting database import..."
|
||||
print_info "Environment: $ENVIRONMENT"
|
||||
print_info "Container: $CONTAINER_NAME"
|
||||
print_info "File: $IMPORT_FILE"
|
||||
print_info "Format: $IMPORT_FORMAT"
|
||||
print_info "Database: $DATABASE_NAME"
|
||||
@@ -276,6 +376,8 @@ echo ""
|
||||
print_info "==============================================="
|
||||
print_info "Database Import Complete!"
|
||||
print_info "==============================================="
|
||||
print_info "Environment: $ENVIRONMENT"
|
||||
print_info "Container: $CONTAINER_NAME"
|
||||
print_info "Database: $DATABASE_NAME"
|
||||
print_info "Tables: $TABLE_COUNT"
|
||||
if [ "$BACKUP_EXISTING" = true ] && [ -n "$BACKUP_FILE" ]; then
|
||||
|
||||
Reference in New Issue
Block a user