Refactor middleware import path, update Docker configurations, and normalize API base URL
This commit is contained in:
@@ -124,7 +124,7 @@ class LicenseValidationMiddleware(BaseHTTPMiddleware):
|
||||
db = CoreSessionLocal()
|
||||
try:
|
||||
# Importar aquí para evitar imports circulares
|
||||
from api.v1.modules.a76.licenses.service import LicenseService
|
||||
from api.v1.modules.core.licenses.service import LicenseService
|
||||
|
||||
license_service = LicenseService(db)
|
||||
license_info = license_service.validate_license(tenant_id)
|
||||
|
||||
@@ -9,7 +9,7 @@ services:
|
||||
POSTGRES_PASSWORD: ${POSTGRES_APP_PASSWORD:-postgres}
|
||||
POSTGRES_INITDB_ARGS: "--encoding=UTF8"
|
||||
ports:
|
||||
- "5432:5432"
|
||||
- "5939:5432"
|
||||
volumes:
|
||||
- postgres_app_data:/var/lib/postgresql/data
|
||||
- ./scripts/postgres-app-entrypoint.sh:/docker-entrypoint-initdb.d/init-app.sh:ro
|
||||
@@ -45,7 +45,7 @@ services:
|
||||
POSTGRES_PASSWORD: ${POSTGRES_KEYCLOAK_PASSWORD:-postgres}
|
||||
POSTGRES_INITDB_ARGS: "--encoding=UTF8"
|
||||
ports:
|
||||
- "5433:5432"
|
||||
- "5233:5432"
|
||||
volumes:
|
||||
- postgres_keycloak_data:/var/lib/postgresql/data
|
||||
- ./scripts/postgres-keycloak-entrypoint.sh:/docker-entrypoint-initdb.d/init-keycloak.sh:ro
|
||||
@@ -94,12 +94,14 @@ services:
|
||||
KC_PROXY_HEADERS: "xforwarded"
|
||||
KC_HEALTH_ENABLED: "true"
|
||||
KC_METRICS_ENABLED: "true"
|
||||
KC_HOSTNAME_PATH: /kcauth
|
||||
KC_LOG_LEVEL: INFO
|
||||
JAVA_OPTS_APPEND: "-Xms256m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
|
||||
command:
|
||||
- start-dev
|
||||
- --db=postgres
|
||||
- --db-url-host=postgres-keycloak
|
||||
- --http-relative-path=/kcauth
|
||||
- --db-url-port=5432
|
||||
- --db-url-database=keycloak
|
||||
- --db-username=postgres
|
||||
@@ -108,7 +110,7 @@ services:
|
||||
- --hostname-strict=false
|
||||
- --proxy-headers=xforwarded
|
||||
ports:
|
||||
- "8080:8080"
|
||||
- "8880:8080"
|
||||
- "9000:9000"
|
||||
depends_on:
|
||||
postgres-keycloak:
|
||||
@@ -120,11 +122,11 @@ services:
|
||||
- backend-net
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "exec 3<>/dev/tcp/127.0.0.1/9000; echo -e 'GET /health/ready HTTP/1.1\r\nhost: 127.0.0.1\r\nConnection: close\r\n\r\n' >&3; grep -q 'HTTP/1.1 200' <&3 || exit 1"]
|
||||
test: ["CMD-SHELL", "exec 3<>/dev/tcp/127.0.0.1/9000; echo -e 'GET /kcauth/health/ready HTTP/1.1\r\nhost: 127.0.0.1\r\nConnection: close\r\n\r\n' >&3; grep -q 'HTTP/1.1 200' <&3 || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 30
|
||||
start_period: 90s
|
||||
start_period: 30s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
@@ -155,15 +157,17 @@ services:
|
||||
- KEYCLOAK_REALM=${KEYCLOAK_REALM:-master}
|
||||
- KEYCLOAK_CLIENT_ID=${KEYCLOAK_CLIENT_ID:-anexo76-backend}
|
||||
- KEYCLOAK_CLIENT_SECRET=${KEYCLOAK_CLIENT_SECRET:-dev-secret}
|
||||
- CORS_ORIGINS=${CORS_ORIGINS:-http://localhost:5173,http://localhost:3000}
|
||||
- CORS_ORIGINS=${CORS_ORIGINS:-https://anexo76-dev.aduanasoft.com,http://localhost:3000}
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "3467:8000"
|
||||
depends_on:
|
||||
postgres-a76:
|
||||
condition: service_healthy
|
||||
keycloak:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- ./backend:/app
|
||||
- backend_cache:/app/__pycache__
|
||||
- ./scripts/backend-entrypoint.sh:/entrypoint.sh:ro
|
||||
networks:
|
||||
- backend-net
|
||||
@@ -191,21 +195,27 @@ services:
|
||||
|
||||
# Frontend - SvelteKit
|
||||
frontend:
|
||||
image: dev.aduanasoft.com/anexo76/frontend:latest
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile.prod
|
||||
args:
|
||||
- BUILDKIT_INLINE_CACHE=1
|
||||
- VITE_API_URL=https://anexo76-dev.aduanasoft.com/api/
|
||||
- VITE_KEYCLOAK_URL=https://anexo76-dev.aduanasoft.com/kcauth/
|
||||
container_name: anexo76-frontend
|
||||
environment:
|
||||
- NODE_ENV=${NODE_ENV:-development}
|
||||
- VITE_API_URL=${VITE_API_URL:-http://localhost:8000/api/}
|
||||
- VITE_API_URL=${VITE_API_URL:-https://anexo76-dev.aduanasoft.com/api}
|
||||
- INTERNAL_API_URL=${INTERNAL_API_URL:-http://backend:8000/api/}
|
||||
- VITE_KEYCLOAK_URL=${VITE_KEYCLOAK_URL:-http://localhost:8080}
|
||||
- VITE_KEYCLOAK_URL=${VITE_KEYCLOAK_URL:-https://anexo76-dev.aduanasoft.com/kcauth/}
|
||||
- VITE_KEYCLOAK_REALM=${VITE_KEYCLOAK_REALM:-master}
|
||||
- VITE_KEYCLOAK_CLIENT_ID=${VITE_KEYCLOAK_CLIENT_ID:-anexo76-frontend}
|
||||
- KEYCLOAK_URL=${KEYCLOAK_URL:-http://keycloak:8080}
|
||||
- KEYCLOAK_URL=${KEYCLOAK_URL:-http://keycloak:8080/kcauth}
|
||||
- KEYCLOAK_REALM=${KEYCLOAK_REALM:-master}
|
||||
- KEYCLOAK_CLIENT_ID=${KEYCLOAK_CLIENT_ID:-anexo76-backend}
|
||||
- KEYCLOAK_CLIENT_SECRET=${KEYCLOAK_CLIENT_SECRET:-zRU5NuvUFtBSOuh7Kdc372AItoWGLgz9}
|
||||
ports:
|
||||
- "5173:5173"
|
||||
- "5111:5173"
|
||||
depends_on:
|
||||
backend:
|
||||
condition: service_healthy
|
||||
@@ -216,7 +226,7 @@ services:
|
||||
- frontend-net
|
||||
- auth-net
|
||||
restart: unless-stopped
|
||||
command: ["pnpm", "run", "dev", "--", "--host", "0.0.0.0"]
|
||||
command: ["node", "build"]
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:5173/ || exit 1"]
|
||||
interval: 15s
|
||||
@@ -253,4 +263,4 @@ networks:
|
||||
auth-net:
|
||||
driver: bridge
|
||||
frontend-net:
|
||||
driver: bridge
|
||||
driver: bridge
|
||||
|
||||
@@ -33,6 +33,9 @@ FROM node:22-alpine AS runtime
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm config set strict-ssl false && \
|
||||
npm install -g pnpm
|
||||
|
||||
# Crear usuario no-root para seguridad antes de copiar con --chown
|
||||
RUN addgroup -g 1001 -S nodejs
|
||||
RUN adduser -S svelte -u 1001
|
||||
@@ -45,12 +48,12 @@ COPY --from=build --chown=svelte:nodejs /app/node_modules ./node_modules
|
||||
USER svelte
|
||||
|
||||
# Puerto para SvelteKit con adapter-node
|
||||
EXPOSE 3000
|
||||
EXPOSE 5173
|
||||
|
||||
# Variables de entorno
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
ENV PORT=5173
|
||||
ENV HOST=0.0.0.0
|
||||
|
||||
# Ejecutar aplicación con Node.js
|
||||
CMD ["node", "build"]
|
||||
CMD ["node", "build"]
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
import { getToken } from './auth';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
const API_BASE_URL = import.meta.env.VITE_API_URL;
|
||||
// Normalize API_BASE_URL to remove trailing slash
|
||||
const API_BASE_URL = (import.meta.env.VITE_API_URL || '').replace(/\/+$/, '');
|
||||
|
||||
export interface ApiResponse<T = any> {
|
||||
data?: T;
|
||||
|
||||
@@ -6,7 +6,11 @@ import { sveltekit } from '@sveltejs/kit/vite';
|
||||
export default defineConfig({
|
||||
server: {
|
||||
port: 5173, // fija el puerto
|
||||
host: true // escucha en 0.0.0.0
|
||||
host: true, // escucha en 0.0.0.0
|
||||
allowedHosts: [
|
||||
'anexo76-dev.aduanasoft.com',
|
||||
// 'otro-host.com' si necesitas más
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
tailwindcss(),
|
||||
|
||||
Reference in New Issue
Block a user