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

This commit is contained in:
Eric Gullickson
2025-12-30 20:50:52 -06:00
parent 4e04d3915c
commit c9b756727e
4 changed files with 232 additions and 22 deletions

View File

@@ -49,6 +49,7 @@
- gnupg - gnupg
- jq - jq
- nodejs - nodejs
- make
state: present state: present
# ============================================ # ============================================

View File

@@ -26,10 +26,10 @@ const features = [
imageAlt: 'Document Storage', imageAlt: 'Document Storage',
}, },
{ {
title: 'Service Stations', title: 'Fuel Stations',
description: 'Find and track your favorite service stations and fuel locations.', description: 'Find and track your favorite service stations and fuel locations.',
imageSrc: 'https://images.unsplash.com/photo-1594940887841-4996b7f80874?w=600&h=400&fit=crop', imageSrc: 'https://images.unsplash.com/photo-1572281335102-5f780686ee91?ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&fit=crop&crop=focalpoint&fp-x=0.5&fp-y=0.6&q=80&auto=format&ixlib=rb-4.1.0&w=600&h=400',
imageAlt: 'Service Stations', imageAlt: 'Fuel Stations',
}, },
{ {
title: 'Reports & Analytics', title: 'Reports & Analytics',

View File

@@ -9,6 +9,7 @@ set -e
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
# Configuration # Configuration
@@ -16,14 +17,17 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
EXPORT_DIR="${PROJECT_ROOT}/database-exports" EXPORT_DIR="${PROJECT_ROOT}/database-exports"
TIMESTAMP=$(date +%Y%m%d_%H%M%S) TIMESTAMP=$(date +%Y%m%d_%H%M%S)
CONTAINER_NAME="mvp-postgres"
# Environment-based container names
CONTAINER_NAME="" # Will be set based on environment selection
ENVIRONMENT="" # production or staging
# Default values # Default values
EXPORT_FORMAT="sql" EXPORT_FORMAT="sql"
COMPRESS=true COMPRESS=true
INCLUDE_SCHEMA=true INCLUDE_SCHEMA=true
INCLUDE_DATA=true INCLUDE_DATA=true
EXPORT_NAME="motovaultpro_export_${TIMESTAMP}" EXPORT_NAME="" # Will be set after environment selection
# Function to print colored output # Function to print colored output
print_info() { print_info() {
@@ -38,6 +42,69 @@ print_error() {
echo -e "${RED}[ERROR]${NC} $1" 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 Export${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
echo "Select environment to export from:"
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 # Function to show usage
show_usage() { show_usage() {
cat << EOF cat << EOF
@@ -47,6 +114,7 @@ Usage: $0 [options]
Options: Options:
-h, --help Show this help message -h, --help Show this help message
-e, --env ENV Environment: production or staging (prompts if not specified)
-f, --format FORMAT Export format: sql, custom, directory (default: sql) -f, --format FORMAT Export format: sql, custom, directory (default: sql)
-o, --output NAME Custom export filename (without extension) -o, --output NAME Custom export filename (without extension)
-n, --no-compress Don't compress the export -n, --no-compress Don't compress the export
@@ -54,20 +122,30 @@ Options:
--data-only Export data only (no schema) --data-only Export data only (no schema)
--exclude-table TABLE Exclude specific table(s) (can be used multiple times) --exclude-table TABLE Exclude specific table(s) (can be used multiple times)
--include-table TABLE Include only specific table(s) (can be used multiple times) --include-table TABLE Include only specific table(s) (can be used multiple times)
-c, --container NAME Container name (default: mvp-postgres) -c, --container NAME Override container name (ignores environment selection)
Environments:
production (prod) Uses container: mvp-postgres
staging (stage) Uses container: mvp-postgres-staging
Examples: Examples:
# Full database export with compression # Interactive environment selection
$0 $0
# Schema only export # Export from production
$0 --schema-only $0 --env production
# Export specific tables # Export from staging
$0 --include-table vehicles --include-table fuel_logs $0 --env staging
# Schema only export from production
$0 --env prod --schema-only
# Export specific tables from staging
$0 -e staging --include-table vehicles --include-table fuel_logs
# Custom format for pg_restore # Custom format for pg_restore
$0 --format custom --output my_backup $0 --env production --format custom --output my_backup
EOF EOF
exit 0 exit 0
@@ -76,12 +154,17 @@ EOF
# Parse command line arguments # Parse command line arguments
EXCLUDE_TABLES=() EXCLUDE_TABLES=()
INCLUDE_TABLES=() INCLUDE_TABLES=()
CONTAINER_OVERRIDE=""
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
-h|--help) -h|--help)
show_usage show_usage
;; ;;
-e|--env)
ENVIRONMENT="$2"
shift 2
;;
-f|--format) -f|--format)
EXPORT_FORMAT="$2" EXPORT_FORMAT="$2"
shift 2 shift 2
@@ -111,7 +194,7 @@ while [[ $# -gt 0 ]]; do
shift 2 shift 2
;; ;;
-c|--container) -c|--container)
CONTAINER_NAME="$2" CONTAINER_OVERRIDE="$2"
shift 2 shift 2
;; ;;
*) *)
@@ -121,6 +204,25 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# 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
# Set default export name with environment prefix
if [ -z "$EXPORT_NAME" ]; then
EXPORT_NAME="motovaultpro_${ENVIRONMENT}_export_${TIMESTAMP}"
fi
# Create export directory if it doesn't exist # Create export directory if it doesn't exist
mkdir -p "${EXPORT_DIR}" mkdir -p "${EXPORT_DIR}"
@@ -186,6 +288,7 @@ fi
# Export database # Export database
print_info "Starting database export..." print_info "Starting database export..."
print_info "Environment: ${ENVIRONMENT}"
print_info "Container: ${CONTAINER_NAME}" print_info "Container: ${CONTAINER_NAME}"
print_info "Format: ${EXPORT_FORMAT}" print_info "Format: ${EXPORT_FORMAT}"
print_info "Output: ${OUTPUT_PATH}" print_info "Output: ${OUTPUT_PATH}"
@@ -221,6 +324,8 @@ METADATA_FILE="${EXPORT_DIR}/${EXPORT_NAME}_metadata.json"
cat > "${METADATA_FILE}" << EOF cat > "${METADATA_FILE}" << EOF
{ {
"export_timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)", "export_timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"environment": "${ENVIRONMENT}",
"container_name": "${CONTAINER_NAME}",
"database_name": "motovaultpro", "database_name": "motovaultpro",
"export_format": "${EXPORT_FORMAT}", "export_format": "${EXPORT_FORMAT}",
"compressed": ${COMPRESS}, "compressed": ${COMPRESS},
@@ -324,6 +429,8 @@ echo ""
print_info "===============================================" print_info "==============================================="
print_info "Database Export Complete!" print_info "Database Export Complete!"
print_info "===============================================" print_info "==============================================="
print_info "Environment: ${ENVIRONMENT}"
print_info "Container: ${CONTAINER_NAME}"
print_info "Export file: ${OUTPUT_PATH}" print_info "Export file: ${OUTPUT_PATH}"
print_info "Metadata: ${METADATA_FILE}" print_info "Metadata: ${METADATA_FILE}"
print_info "Instructions: ${IMPORT_INSTRUCTIONS}" print_info "Instructions: ${IMPORT_INSTRUCTIONS}"

View File

@@ -9,14 +9,18 @@ set -e
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
# Configuration # Configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
CONTAINER_NAME="mvp-postgres"
DATABASE_NAME="motovaultpro" DATABASE_NAME="motovaultpro"
# Environment-based container names
CONTAINER_NAME="" # Will be set based on environment selection
ENVIRONMENT="" # production or staging
# Default values # Default values
BACKUP_EXISTING=true BACKUP_EXISTING=true
DROP_EXISTING=false DROP_EXISTING=false
@@ -36,6 +40,69 @@ print_error() {
echo -e "${RED}[ERROR]${NC} $1" 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 # Function to show usage
show_usage() { show_usage() {
cat << EOF cat << EOF
@@ -45,7 +112,8 @@ Usage: $0 [options] <export-file>
Options: Options:
-h, --help Show this help message -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) -d, --database NAME Database name (default: motovaultpro)
--create-db Create database if it doesn't exist --create-db Create database if it doesn't exist
--drop-existing Drop existing database before import (DANGER!) --drop-existing Drop existing database before import (DANGER!)
@@ -53,15 +121,25 @@ Options:
--force Skip confirmation prompts --force Skip confirmation prompts
-f, --format FORMAT Import format: sql, custom, directory (auto-detected if not specified) -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: Examples:
# Import a standard SQL dump # Interactive environment selection
$0 database-exports/motovaultpro_export_20250101_120000.sql.gz $0 database-exports/backup.sql.gz
# Import with database recreation # Import to production
$0 --drop-existing --create-db backup.sql $0 --env production database-exports/backup.sql.gz
# Import custom format # Import to staging
$0 --format custom backup.dump $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: Safety Features:
- Creates backup of existing database by default - Creates backup of existing database by default
@@ -74,13 +152,19 @@ EOF
} }
# Parse command line arguments # Parse command line arguments
CONTAINER_OVERRIDE=""
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
-h|--help) -h|--help)
show_usage show_usage
;; ;;
-e|--env)
ENVIRONMENT="$2"
shift 2
;;
-c|--container) -c|--container)
CONTAINER_NAME="$2" CONTAINER_OVERRIDE="$2"
shift 2 shift 2
;; ;;
-d|--database) -d|--database)
@@ -129,6 +213,20 @@ if [ ! -e "$IMPORT_FILE" ]; then
exit 1 exit 1
fi 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 # Auto-detect format if not specified
if [ -z "$IMPORT_FORMAT" ]; then if [ -z "$IMPORT_FORMAT" ]; then
if [[ "$IMPORT_FILE" == *.sql.gz ]]; then if [[ "$IMPORT_FILE" == *.sql.gz ]]; then
@@ -205,6 +303,8 @@ fi
# Import based on format # Import based on format
print_info "Starting database import..." print_info "Starting database import..."
print_info "Environment: $ENVIRONMENT"
print_info "Container: $CONTAINER_NAME"
print_info "File: $IMPORT_FILE" print_info "File: $IMPORT_FILE"
print_info "Format: $IMPORT_FORMAT" print_info "Format: $IMPORT_FORMAT"
print_info "Database: $DATABASE_NAME" print_info "Database: $DATABASE_NAME"
@@ -276,6 +376,8 @@ echo ""
print_info "===============================================" print_info "==============================================="
print_info "Database Import Complete!" print_info "Database Import Complete!"
print_info "===============================================" print_info "==============================================="
print_info "Environment: $ENVIRONMENT"
print_info "Container: $CONTAINER_NAME"
print_info "Database: $DATABASE_NAME" print_info "Database: $DATABASE_NAME"
print_info "Tables: $TABLE_COUNT" print_info "Tables: $TABLE_COUNT"
if [ "$BACKUP_EXISTING" = true ] && [ -n "$BACKUP_FILE" ]; then if [ "$BACKUP_EXISTING" = true ] && [ -n "$BACKUP_FILE" ]; then