fix issue prod deployment
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import Link from 'next/link'
|
||||
import { formatCurrency } from '@rentaldrivego/types'
|
||||
import { formatCurrency, SupportedCurrency } from '@rentaldrivego/types'
|
||||
import { apiFetch } from '@/lib/api'
|
||||
import { useDashboardI18n } from '@/components/I18nProvider'
|
||||
|
||||
@@ -25,7 +25,7 @@ type PaymentRow = {
|
||||
id: string
|
||||
reservationId: string
|
||||
amount: number
|
||||
currency: string
|
||||
currency: SupportedCurrency
|
||||
status: string
|
||||
type: 'CHARGE' | 'DEPOSIT'
|
||||
paymentProvider: 'AMANPAY' | 'PAYPAL'
|
||||
|
||||
@@ -31,6 +31,12 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.production
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:4000/health"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 6
|
||||
start_period: 30s
|
||||
command:
|
||||
- bash
|
||||
- -c
|
||||
@@ -75,6 +81,12 @@ services:
|
||||
NEXT_PUBLIC_MARKETPLACE_URL: ${NEXT_PUBLIC_MARKETPLACE_URL}
|
||||
NEXT_PUBLIC_DASHBOARD_URL: ${NEXT_PUBLIC_DASHBOARD_URL}
|
||||
NEXT_PUBLIC_ADMIN_URL: ${NEXT_PUBLIC_ADMIN_URL}
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 6
|
||||
start_period: 30s
|
||||
command: ["npm", "run", "start", "--workspace", "@rentaldrivego/marketplace"]
|
||||
networks:
|
||||
- internal
|
||||
@@ -104,6 +116,12 @@ services:
|
||||
NEXT_PUBLIC_MARKETPLACE_URL: ${NEXT_PUBLIC_MARKETPLACE_URL}
|
||||
NEXT_PUBLIC_DASHBOARD_URL: ${NEXT_PUBLIC_DASHBOARD_URL}
|
||||
NEXT_PUBLIC_ADMIN_URL: ${NEXT_PUBLIC_ADMIN_URL}
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3001/"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 6
|
||||
start_period: 30s
|
||||
command: ["npm", "run", "start", "--workspace", "@rentaldrivego/dashboard"]
|
||||
networks:
|
||||
- internal
|
||||
@@ -133,6 +151,12 @@ services:
|
||||
NEXT_PUBLIC_MARKETPLACE_URL: ${NEXT_PUBLIC_MARKETPLACE_URL}
|
||||
NEXT_PUBLIC_DASHBOARD_URL: ${NEXT_PUBLIC_DASHBOARD_URL}
|
||||
NEXT_PUBLIC_ADMIN_URL: ${NEXT_PUBLIC_ADMIN_URL}
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3002/"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 6
|
||||
start_period: 30s
|
||||
command: ["npm", "run", "start", "--workspace", "@rentaldrivego/admin"]
|
||||
networks:
|
||||
- internal
|
||||
|
||||
@@ -53,6 +53,34 @@ start_prod_services() {
|
||||
prod_compose up --build -d "$@"
|
||||
}
|
||||
|
||||
wait_for_healthy() {
|
||||
local service="$1"
|
||||
local timeout="${2:-120}"
|
||||
local container="${PROJECT_NAME}-${service}-1"
|
||||
local elapsed=0
|
||||
|
||||
echo "Waiting for ${service} to be healthy (timeout: ${timeout}s)..."
|
||||
while [[ $elapsed -lt $timeout ]]; do
|
||||
local status
|
||||
status=$(docker inspect --format='{{.State.Health.Status}}' "${container}" 2>/dev/null || echo "missing")
|
||||
case "$status" in
|
||||
healthy)
|
||||
echo "${service} is healthy."
|
||||
return 0
|
||||
;;
|
||||
unhealthy)
|
||||
echo "ERROR: ${service} is unhealthy. Check logs with: docker logs ${container}" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
sleep 5
|
||||
elapsed=$((elapsed + 5))
|
||||
done
|
||||
|
||||
echo "ERROR: Timed out waiting for ${service} to become healthy." >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
start_portainer() {
|
||||
ensure_env_file
|
||||
ensure_traefik_network
|
||||
|
||||
@@ -6,5 +6,6 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
source "${ROOT_DIR}/scripts/docker-prod-common.sh"
|
||||
|
||||
start_prod_services admin
|
||||
wait_for_healthy admin
|
||||
|
||||
echo "Admin is starting."
|
||||
echo "Admin is up and healthy."
|
||||
|
||||
@@ -7,5 +7,9 @@ source "${ROOT_DIR}/scripts/docker-prod-common.sh"
|
||||
|
||||
start_traefik
|
||||
start_prod_services
|
||||
wait_for_healthy api
|
||||
wait_for_healthy marketplace
|
||||
wait_for_healthy dashboard
|
||||
wait_for_healthy admin
|
||||
|
||||
echo "Production stack is starting: traefik, postgres, redis, api, marketplace, dashboard, admin, pgmanage"
|
||||
echo "Production stack is up and healthy: traefik, postgres, redis, api, marketplace, dashboard, admin, pgmanage"
|
||||
|
||||
@@ -6,5 +6,6 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
source "${ROOT_DIR}/scripts/docker-prod-common.sh"
|
||||
|
||||
start_prod_services api
|
||||
wait_for_healthy api
|
||||
|
||||
echo "API is starting."
|
||||
echo "API is up and healthy."
|
||||
|
||||
@@ -6,5 +6,6 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
source "${ROOT_DIR}/scripts/docker-prod-common.sh"
|
||||
|
||||
start_prod_services dashboard
|
||||
wait_for_healthy dashboard
|
||||
|
||||
echo "Dashboard is starting."
|
||||
echo "Dashboard is up and healthy."
|
||||
|
||||
@@ -6,5 +6,8 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
source "${ROOT_DIR}/scripts/docker-prod-common.sh"
|
||||
|
||||
start_prod_services marketplace dashboard admin
|
||||
wait_for_healthy marketplace
|
||||
wait_for_healthy dashboard
|
||||
wait_for_healthy admin
|
||||
|
||||
echo "Frontend production services are starting: marketplace, dashboard, admin"
|
||||
echo "All frontend services are up and healthy."
|
||||
|
||||
@@ -6,5 +6,6 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
source "${ROOT_DIR}/scripts/docker-prod-common.sh"
|
||||
|
||||
start_prod_services marketplace
|
||||
wait_for_healthy marketplace
|
||||
|
||||
echo "Marketplace is starting."
|
||||
echo "Marketplace is up and healthy."
|
||||
|
||||
Reference in New Issue
Block a user