Updated for docker images of FE BE on local
This commit is contained in:
parent
ac77c4a21e
commit
773f62ce07
44
compose.yaml
44
compose.yaml
|
|
@ -58,5 +58,49 @@ services:
|
|||
timeout: 3s
|
||||
retries: 10
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile.backend
|
||||
environment:
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-atb}:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env; see .env.example}@postgres:5432/${POSTGRES_DB:-atb}
|
||||
VALKEY_URL: valkey://valkey:6379/0
|
||||
KEYCLOAK_ISSUER: ${KEYCLOAK_ISSUER:-http://keycloak:8080/auth/realms/atb}
|
||||
KEYCLOAK_CLIENT_ID: ${KEYCLOAK_CLIENT_ID:-atb-portal}
|
||||
KEYCLOAK_CLIENT_SECRET: ${KEYCLOAK_CLIENT_SECRET:-}
|
||||
USE_IDENTITY_MOCK: ${USE_IDENTITY_MOCK:-True}
|
||||
ENVIRONMENT: ${ENVIRONMENT:-development}
|
||||
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
||||
ports:
|
||||
- "127.0.0.1:8000:8000"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
valkey:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -f http://127.0.0.1:8000/health || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 15s
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile.frontend
|
||||
ports:
|
||||
- "${PORTAL_PORT:-3000}:80"
|
||||
depends_on:
|
||||
backend:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://127.0.0.1/healthz || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 5s
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ The services publish ports on loopback only:
|
|||
| PostgreSQL | `127.0.0.1:5432` | `atb` database and user from `.env` |
|
||||
| Keycloak | <http://localhost:8080> | Local identity server; admin credentials from `.env` |
|
||||
| Valkey | `127.0.0.1:6379` | Local cache/stream dependency |
|
||||
| Backend | `127.0.0.1:8000` | FastAPI application API (Swagger docs at `/docs`) |
|
||||
| Frontend | `http://localhost:3000` | Hardened Nginx reverse proxy & React SPA portal |
|
||||
|
||||
PostgreSQL also creates a separate `keycloak` database and login for Keycloak. Both databases share one local PostgreSQL container; this is a workstation convenience, not a production isolation recommendation. PostgreSQL data survives `docker compose down` in the named `postgres_data` volume. Valkey is intentionally ephemeral because the durable outbox belongs in PostgreSQL.
|
||||
|
||||
|
|
@ -48,6 +50,6 @@ To erase the local PostgreSQL data as well, add `--volumes` to the `down` comman
|
|||
|
||||
The example uses the [PostgreSQL Docker Official Image](https://hub.docker.com/_/postgres), [Keycloak's official container image](https://www.keycloak.org/server/containers) from `quay.io/keycloak/keycloak`, and the [Valkey project's image](https://hub.docker.com/r/valkey/valkey). Release tags are pinned in `project_code/.env.example`; they are not immutable digest pins, and this repository has not configured image signature verification or a vendor certification policy. Review and update the selected tags through normal dependency maintenance.
|
||||
|
||||
The current repository has no application API, worker, frontend, migration, or test-runner source to build. Those services should be added to this Compose project as their implementation and test artifacts are authored; this file does not use placeholder build contexts. Mail capture, object-storage emulation, reverse proxy, and observability services are also omitted until their iteration needs and providers are selected.
|
||||
The Compose project includes the core FastAPI backend API and hardened React SPA frontend services authored during Construction iterations, building directly from `docker/Dockerfile.backend` and `docker/Dockerfile.frontend`. Mail capture, object-storage emulation, and external observability services remain optional overlays until their iteration needs and providers are selected.
|
||||
|
||||
This Compose configuration does not select a production runtime, change the approved production availability/recovery requirements, or demonstrate production readiness. Production hosting and its evidence gates remain open in the deployment design.
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ export const CallbackView: React.FC = () => {
|
|||
|
||||
// Verify session with backend API
|
||||
setStatus('Initializing application session...');
|
||||
const sessionResp = await fetch('http://localhost:8000/api/v1/auth/session', {
|
||||
const sessionResp = await fetch('/api/v1/auth/session', {
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { Card } from '../../components/ui/Card';
|
|||
import { ShieldCheck, LogIn, ChevronRight } from 'lucide-react';
|
||||
|
||||
export const LoginView: React.FC = () => {
|
||||
const [selectedPersona, setSelectedPersona] = useState<string>('buyer@alpha.com');
|
||||
const [selectedPersona, setSelectedPersona] = useState<string>('buyer@malwa-agri.demo');
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||
|
||||
|
|
@ -74,15 +74,25 @@ export const LoginView: React.FC = () => {
|
|||
setIsLoading(true);
|
||||
setErrorMessage(null);
|
||||
try {
|
||||
const isDemo = selectedPersona.endsWith('@malwa-agri.demo');
|
||||
const tenantId = isDemo ? 'demo-malwa-agri' : 'tenant-alpha';
|
||||
|
||||
const role = selectedPersona.includes('buyer') ? 'Mandi Buyer' :
|
||||
selectedPersona.includes('pmgr') ? 'Purchase Manager' :
|
||||
selectedPersona.includes('qc') ? 'Quality Officer' :
|
||||
selectedPersona.includes('yard') || selectedPersona.includes('whmgr') ? 'Yard Supervisor' :
|
||||
selectedPersona.includes('smgr') ? 'Sales Manager' :
|
||||
selectedPersona.includes('sales') ? 'Sales Executive' :
|
||||
selectedPersona.includes('logistics') ? 'Logistics Coordinator' :
|
||||
selectedPersona.includes('finance') ? 'Accounts Executive' :
|
||||
selectedPersona.includes('director') ? 'Partner / MD' : 'Tenant Administrator';
|
||||
|
||||
authStore.setSession(`mock_token_${selectedPersona}`, {
|
||||
sub: `usr_${selectedPersona}`,
|
||||
email: selectedPersona,
|
||||
name: selectedPersona.split('@')[0],
|
||||
roles: selectedPersona.includes('buyer') ? ['Mandi Buyer'] :
|
||||
selectedPersona.includes('qc') ? ['Quality Officer'] :
|
||||
selectedPersona.includes('yard') ? ['Yard Supervisor'] :
|
||||
selectedPersona.includes('sales') ? ['Sales Executive'] : ['Tenant Administrator'],
|
||||
tenant_id: 'tenant-alpha'
|
||||
roles: [role],
|
||||
tenant_id: tenantId
|
||||
});
|
||||
window.location.href = '/';
|
||||
} catch (err: any) {
|
||||
|
|
@ -141,12 +151,26 @@ export const LoginView: React.FC = () => {
|
|||
onChange={(e) => setSelectedPersona(e.target.value)}
|
||||
className="w-full py-2 px-3 rounded bg-white border border-card-border text-text-primary text-xs focus:outline-none focus:border-sidebar-surface focus:ring-2 focus:ring-secondary-amber/20 font-mono transition"
|
||||
>
|
||||
<option value="buyer@alpha.com">Ramesh Kumar — Mandi Buyer</option>
|
||||
<option value="qc@alpha.com">Ananya Sharma — Quality Officer (SoD Restricted)</option>
|
||||
<option value="yard@alpha.com">Vikram Singh — Yard Supervisor (SoD Restricted)</option>
|
||||
<option value="sales@alpha.com">Rohit Verma — Sales Executive (SoD Restricted)</option>
|
||||
<option value="finance@alpha.com">Kavita Joshi — Accounts Executive</option>
|
||||
<option value="admin@alpha.com">Alpha Admin — Tenant Administrator</option>
|
||||
<optgroup label="Sales Demo Firm — Malwa Agri Trading Corp (demo-malwa-agri)">
|
||||
<option value="buyer@malwa-agri.demo">Rajesh Patidar — Mandi Buyer (Journey 1: Sauda Booking)</option>
|
||||
<option value="yard@malwa-agri.demo">Vikram Singh — Yard Supervisor (Journey 2: Gate-In & Gross)</option>
|
||||
<option value="qc@malwa-agri.demo">Dr. Ananya Joshi — Quality Officer (Journey 3: Lab Assay & Rebate)</option>
|
||||
<option value="whmgr@malwa-agri.demo">Gopal Verma — Godown Manager (Journey 4: Stock Ledger)</option>
|
||||
<option value="sales@malwa-agri.demo">Rohit Agrawal — Sales Executive (Journey 5: Sales Order)</option>
|
||||
<option value="smgr@malwa-agri.demo">Meera Nair — Sales Manager (Journey 5: Credit Override)</option>
|
||||
<option value="logistics@malwa-agri.demo">Dinesh Rao — Logistics Coordinator (Journey 6: Bilty Manifest)</option>
|
||||
<option value="finance@malwa-agri.demo">Kavita Maheshwari — Accounts Executive (Journey 7: Mandi Cess)</option>
|
||||
<option value="director@malwa-agri.demo">Harish Patel — Managing Director (Journey 8: Executive P&L)</option>
|
||||
<option value="admin@malwa-agri.demo">Platform Admin — Tenant Administrator</option>
|
||||
</optgroup>
|
||||
<optgroup label="Standard Test Firm — Alpha Agro Traders (tenant-alpha)">
|
||||
<option value="buyer@alpha.com">Ramesh Kumar — Mandi Buyer</option>
|
||||
<option value="qc@alpha.com">Ananya Sharma — Quality Officer</option>
|
||||
<option value="yard@alpha.com">Vikram Singh — Yard Supervisor</option>
|
||||
<option value="sales@alpha.com">Rohit Verma — Sales Executive</option>
|
||||
<option value="finance@alpha.com">Kavita Joshi — Accounts Executive</option>
|
||||
<option value="admin@alpha.com">Alpha Admin — Tenant Administrator</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
|
||||
<Button
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@
|
|||
import { authStore } from '../stores/authStore';
|
||||
import { tenantStore } from '../stores/tenantStore';
|
||||
|
||||
const BASE_URL = process.env.VITE_API_URL || 'http://localhost:8000';
|
||||
const BASE_URL = (typeof process !== 'undefined' && process.env?.VITE_API_URL)
|
||||
? process.env.VITE_API_URL
|
||||
: (typeof window !== 'undefined' ? '' : 'http://localhost:8000');
|
||||
|
||||
export interface ApiResponse<T = any> {
|
||||
data?: T;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ import react from '@vitejs/plugin-react';
|
|||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
define: {
|
||||
'process.env': {},
|
||||
},
|
||||
server: {
|
||||
port: 3000,
|
||||
host: '0.0.0.0',
|
||||
|
|
|
|||
Loading…
Reference in New Issue