new deployablility enhancements

This commit is contained in:
2026-07-17 16:09:25 -07:00
parent 222561c0b7
commit 465e7cb9fb
7 changed files with 45 additions and 164 deletions
+3
View File
@@ -0,0 +1,3 @@
PROJECT_NAME=kmtn
FRONTEND_PORT=4201
KMTN_CORS_ORIGINS='["http://localhost:4201", "http://localhost"]'
+3
View File
@@ -0,0 +1,3 @@
PROJECT_NAME=staylit
FRONTEND_PORT=4200
KMTN_CORS_ORIGINS='["http://localhost:4200", "http://localhost"]'
Executable
+37
View File
@@ -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."
-85
View File
@@ -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:
-25
View File
@@ -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
-52
View File
@@ -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:
+2 -2
View File
@@ -27,7 +27,7 @@ services:
environment: environment:
KMTN_DATABASE_URL: >- KMTN_DATABASE_URL: >-
postgresql+asyncpg://postgres:postgres@/kmountain?host=/var/run/postgresql 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_USERNAME: "admin"
KMTN_ADMIN_PASSWORD: "123" KMTN_ADMIN_PASSWORD: "123"
KMTN_STATIC_UPSTREAM_URL: http://frontend:80 KMTN_STATIC_UPSTREAM_URL: http://frontend:80
@@ -47,7 +47,7 @@ services:
API_UPSTREAM: http://api:8000 API_UPSTREAM: http://api:8000
API_PUBLIC_URL: "" API_PUBLIC_URL: ""
ports: ports:
- "4200:80" - "${FRONTEND_PORT}:80"
volumes: volumes:
- logs:/logs - logs:/logs
depends_on: depends_on: