From 465e7cb9fb6b7afbbe94aa9a74a62a8bdc801165 Mon Sep 17 00:00:00 2001 From: kfj001 Date: Fri, 17 Jul 2026 16:09:25 -0700 Subject: [PATCH] new deployablility enhancements --- customers/.env.kmtn | 3 ++ customers/.env.staylit | 3 ++ deploy-all.sh | 37 ++++++++++++++++++ docker-compose-2.yml | 85 ----------------------------------------- docker-compose.prod.yml | 25 ------------ docker-compose.test.yml | 52 ------------------------- docker-compose.yml | 4 +- 7 files changed, 45 insertions(+), 164 deletions(-) create mode 100644 customers/.env.kmtn create mode 100644 customers/.env.staylit create mode 100755 deploy-all.sh delete mode 100644 docker-compose-2.yml delete mode 100644 docker-compose.prod.yml delete mode 100644 docker-compose.test.yml diff --git a/customers/.env.kmtn b/customers/.env.kmtn new file mode 100644 index 0000000..5a152a6 --- /dev/null +++ b/customers/.env.kmtn @@ -0,0 +1,3 @@ +PROJECT_NAME=kmtn +FRONTEND_PORT=4201 +KMTN_CORS_ORIGINS='["http://localhost:4201", "http://localhost"]' diff --git a/customers/.env.staylit b/customers/.env.staylit new file mode 100644 index 0000000..8cf158f --- /dev/null +++ b/customers/.env.staylit @@ -0,0 +1,3 @@ +PROJECT_NAME=staylit +FRONTEND_PORT=4200 +KMTN_CORS_ORIGINS='["http://localhost:4200", "http://localhost"]' diff --git a/deploy-all.sh b/deploy-all.sh new file mode 100755 index 0000000..940ab60 --- /dev/null +++ b/deploy-all.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Ensure we are in the project root +cd "$(dirname "$0")" + +if [ ! -d "customers" ]; then + echo "Error: 'customers/' directory not found." + exit 1 +fi + +echo "Starting mass deployment for all customers..." +echo "--------------------------------------------------" + +# Iterate through .env.* files in the customers/ directory +for env_file in customers/.env.*; do + # Check if it's a regular file and not just the pattern itself (if no matches found) + [ -e "$env_file" ] || continue + + # Extract customer name from the filename (e.g., customers/.env.kmtn -> kmtn) + # We remove the 'customers/.env.' prefix to get the name + customer_name=$(basename "$env_file" | sed 's/\.env\.//') + + echo "[$(date +'%H:%M:%S')] Deploying: $customer_name" + echo "Using configuration: $env_file" + + # Run docker compose. We use -p for the project name to isolate them correctly. + docker compose --env-file "$env_file" -p "$customer_name" up -d --build + + if [ $? -eq 0 ]; then + echo "[$(date +'%H:%M:%S')] ✅ SUCCESS: $customer_name" + else + echo "[$(date +'%H:%M:%S')] ❌ FAILED: $customer_name" + fi + echo "--------------------------------------------------" +done + +echo "Mass deployment process completed." diff --git a/docker-compose-2.yml b/docker-compose-2.yml deleted file mode 100644 index 773b9c5..0000000 --- a/docker-compose-2.yml +++ /dev/null @@ -1,85 +0,0 @@ -services: - db: - image: docker.io/library/postgres:16-alpine - restart: unless-stopped - # NOTE: Change POSTGRES_PASSWORD in production. Consider using Docker secrets or - # a managed PostgreSQL service instead of local credentials. - environment: - POSTGRES_DB: kmountain - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - volumes: - - pgdata:/var/lib/postgresql/data - - pgsocket:/var/run/postgresql - healthcheck: - test: [ "CMD-SHELL", "pg_isready -U postgres" ] - interval: 5s - timeout: 5s - retries: 5 - - # NOTE: Update KMTN_CORS_ORIGINS in production to your actual domain(s). - # Set KMTN_DATABASE_URL to your managed PostgreSQL connection if not using the local db service. - api: - build: - context: ./backend - dockerfile: Dockerfile - restart: unless-stopped - environment: - KMTN_DATABASE_URL: >- - postgresql+asyncpg://postgres:postgres@/kmountain?host=/var/run/postgresql - KMTN_CORS_ORIGINS: '["http://localhost:4200", "http://localhost"]' - KMTN_ADMIN_USERNAME: "admin" - KMTN_ADMIN_PASSWORD: "123" - KMTN_STATIC_UPSTREAM_URL: http://frontend:80 - volumes: - - pgsocket:/var/run/postgresql - - logs:/logs - depends_on: - db: - condition: service_healthy - - frontend: - build: - context: . - dockerfile: Dockerfile - restart: unless-stopped - environment: - API_UPSTREAM: http://api:8000 - API_PUBLIC_URL: "" - ports: - - "4201:80" - volumes: - - logs:/logs - depends_on: - - api - - # Flutter build container — runs alongside the api/frontend services. - # The api container SSHes directly into this container over the Docker network. - # Forced to linux/amd64 because Android SDK CLI tools are only published - # for x86_64. On Apple Silicon hosts, Docker runs via Rosetta emulation. - build: - build: - context: ./build - dockerfile: Dockerfile - platform: linux/amd64 - restart: unless-stopped - expose: - - "22" - volumes: - - flutter-cache:/home/vscode/.pub-cache - - android-licenses:/opt/android-sdk/licenses - deploy: - resources: - limits: - cpus: '4.0' - memory: 16g - reservations: - cpus: '2.0' - memory: 8g - -volumes: - pgdata: - pgsocket: - logs: - flutter-cache: - android-licenses: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml deleted file mode 100644 index 79da340..0000000 --- a/docker-compose.prod.yml +++ /dev/null @@ -1,25 +0,0 @@ -# Production override — use with: docker compose -f docker-compose.yml -f docker-compose.prod.yml up -# Assumes: managed PostgreSQL, external reverse proxy / load balancer handling TLS and port 80/443. - -services: - # No db service — managed PostgreSQL is assumed. - # Set KMTN_DATABASE_URL in your environment or a .env file. - - api: - environment: - KMTN_ENV: production - # Override with your actual production domain(s) - KMTN_CORS_ORIGINS: '["https://yourdomain.com"]' - volumes: - - logs:/logs - # No port mapping — traffic arrives via reverse proxy / load balancer - - frontend: - environment: - # Internal API target for nginx proxy - API_UPSTREAM: https://api.yourdomain.com - # Browser-facing API URL. Empty = proxy mode. Set to direct URL if ingress breaks proxy chain. - API_PUBLIC_URL: "" - volumes: - - logs:/logs - # No port mapping — traffic arrives via reverse proxy / load balancer diff --git a/docker-compose.test.yml b/docker-compose.test.yml deleted file mode 100644 index e990678..0000000 --- a/docker-compose.test.yml +++ /dev/null @@ -1,52 +0,0 @@ -services: - api: - depends_on: - db: - condition: service_healthy - environment: - KMTN_ADMIN_PASSWORD: 123 - KMTN_ADMIN_USERNAME: admin - KMTN_CORS_ORIGINS: '["http://truenas.local:4200", "http://truenas.local"]' - KMTN_DATABASE_URL: >- - postgresql+asyncpg://postgres:postgres@/kmountain?host=/var/run/postgresql - image: truenas.local:35000/kmtnflower-api:latest - pull_policy: always - ports: - - '8000:8000' - restart: unless-stopped - volumes: - - pgsocket:/var/run/postgresql - - logs:/logs - db: - environment: - POSTGRES_DB: kmountain - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - healthcheck: - interval: 5s - retries: 5 - test: - - CMD-SHELL - - pg_isready -U postgres - timeout: 5s - image: docker.io/library/postgres:16-alpine - restart: unless-stopped - volumes: - - /mnt/WestTek_Mainframe/vm_data/kmtndata:/var/lib/postgresql/data - - pgsocket:/var/run/postgresql - frontend: - depends_on: - - api - environment: - API_PUBLIC_URL: http://truenas.local:8000 - API_UPSTREAM: http://api:8000 - image: truenas.local:35000/kmtnflower:latest - pull_policy: always - ports: - - '4200:80' - restart: unless-stopped - volumes: - - logs:/logs -volumes: - pgsocket: - logs: diff --git a/docker-compose.yml b/docker-compose.yml index 5a9b168..c715633 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: environment: KMTN_DATABASE_URL: >- postgresql+asyncpg://postgres:postgres@/kmountain?host=/var/run/postgresql - KMTN_CORS_ORIGINS: '["http://localhost:4200", "http://localhost"]' + KMTN_CORS_ORIGINS: '${KMTN_CORS_ORIGINS}' KMTN_ADMIN_USERNAME: "admin" KMTN_ADMIN_PASSWORD: "123" KMTN_STATIC_UPSTREAM_URL: http://frontend:80 @@ -47,7 +47,7 @@ services: API_UPSTREAM: http://api:8000 API_PUBLIC_URL: "" ports: - - "4200:80" + - "${FRONTEND_PORT}:80" volumes: - logs:/logs depends_on: