Compare commits
2
Commits
222561c0b7
...
19eb0aee07
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19eb0aee07 | ||
|
|
465e7cb9fb |
+14
-8
@@ -89,12 +89,18 @@ Admin users can create mobile build requests, upload platform signing files, run
|
||||
- Build artifact generation only (`.aab` and `.ipa`).
|
||||
- No automatic App Store Connect / Google Play upload.
|
||||
|
||||
## Common tasks
|
||||
## Deployment
|
||||
|
||||
- **Re-skin:** Edit colors in `_variables.scss` only.
|
||||
- **Add a page:** Create component folder → add route in `app.routes.ts` → add nav link (if needed).
|
||||
- **Update content (dev):** Run the API, then use Swagger UI at [http://localhost:8000/docs](http://localhost:8000/docs) to create/update content.
|
||||
- **Update content (seed):** Edit [backend/seed.py](backend/seed.py) and restart the API (autoseed runs on empty DB), or hit `curl -X POST http://localhost:8000/api/admin/reset` to re-seed.
|
||||
- **Run the app (dev):** From the `backend/` directory, set `KMTN_DATABASE_URL=sqlite+aiosqlite:///./kmountain.db`, then `uvicorn app.main:app --reload` + `ng serve` in parallel. Autoseed populates data on first run.
|
||||
- **Run the app (dev container):** Reopen in Container via VS Code.
|
||||
- **Build:** `ng build` → `dist/`.
|
||||
The project uses a single parameterized `docker-compose.yml` driven by customer-specific `.env` files in the `customers/` directory.
|
||||
|
||||
**Deploy all customers:**
|
||||
```bash
|
||||
./deploy-all.sh
|
||||
```
|
||||
|
||||
**Deploy a specific customer:**
|
||||
```bash
|
||||
docker compose --env-file customers/.env.<customer_name> -p <customer_name> up -d --build
|
||||
```
|
||||
|
||||
*Note: Multiple legacy `docker-compose.yml` files have been removed in favor of this template system.*
|
||||
|
||||
@@ -67,10 +67,8 @@ Open [http://localhost:4200](http://localhost:4200) and ensure the backend is ru
|
||||
|
||||
```
|
||||
.
|
||||
├── docker-compose.yml # Dev compose (builds from source)
|
||||
├── docker-compose.prod.yml # Prod override (applied with -f docker-compose.yml -f docker-compose.prod.yml)
|
||||
├── docker-compose.dev.yml # Dev-sidecar compose (dev container)
|
||||
├── Dockerfile # Frontend: Node build stage + Nginx serve stage
|
||||
├── docker-compose.yml # Parameterized base template
|
||||
├── .devcontainer/ # VS Code dev container
|
||||
├── docker-entrypoint.sh # Renders nginx config + config.json from env vars
|
||||
├── nginx.conf.template # Nginx config template (envsubst)
|
||||
├── config.json.template # Runtime API config template (envsubst)
|
||||
@@ -292,11 +290,19 @@ Full interactive API docs at [http://localhost:8000/docs](http://localhost:8000/
|
||||
|
||||
## Deployment
|
||||
|
||||
### Docker Compose (recommended)
|
||||
To deploy a customer environment, use the `deploy-all.sh` script to deploy everyone:
|
||||
|
||||
The app ships as two Docker images — a frontend (Angular + Nginx) and a backend (FastAPI + gunicorn). Build, tag, and push them to your registry, then deploy with Docker Compose.
|
||||
```bash
|
||||
./deploy-all.sh
|
||||
```
|
||||
|
||||
#### Build and push
|
||||
Or deploy a specific customer using their `.env` file:
|
||||
|
||||
```bash
|
||||
docker compose --env-file customers/.env.<customer_name> -p <customer_name> up -d --build
|
||||
```
|
||||
|
||||
The `docker-compose.yml` file is a parameterized template.
|
||||
|
||||
```bash
|
||||
# Frontend
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
PROJECT_NAME=kmtn
|
||||
FRONTEND_PORT=4201
|
||||
KMTN_CORS_ORIGINS='["http://localhost:4201", "http://localhost"]'
|
||||
@@ -0,0 +1,3 @@
|
||||
PROJECT_NAME=staylit
|
||||
FRONTEND_PORT=4200
|
||||
KMTN_CORS_ORIGINS='["http://localhost:4200", "http://localhost"]'
|
||||
Executable
+37
@@ -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."
|
||||
@@ -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:
|
||||
@@ -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
|
||||
@@ -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
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user