This commit is contained in:
David Arranz 2025-11-04 10:12:05 +01:00
parent cecba33ebb
commit fc952b948e
20 changed files with 43 additions and 42 deletions

View File

@ -30,20 +30,7 @@ COPY modules ./modules
RUN npx --yes turbo@2.5.8 prune @erp/factuges-server --docker
########################
# 2) Instalar deps de la parte pruned (usando pnpm fetch para cache)
########################
#FROM base AS installer
# Traemos lockfile y pnpm-store desde la etapa prune
#COPY --from=pruner /repo/out/json/ ./
#COPY --from=pruner /repo/out/pnpm-lock.yaml ./pnpm-lock.yaml
# Prefetch a store global (rápido y cacheable)
#RUN pnpm fetch
#RUN pnpm install --frozen-lockfile
########################
# 3) Builder: código + link deps y build
# 2) Builder: código + link deps y build
########################
FROM base AS builder
@ -62,7 +49,7 @@ RUN pnpm install --frozen-lockfile --prefer-offline
RUN pnpm -w turbo run build --filter=@erp/factuges-server...
########################
# 4) Runner minimal
# 3) Runner minimal
########################
#FROM ${NODE_IMAGE} AS runner
FROM base AS runner
@ -91,4 +78,5 @@ COPY --from=builder /repo/apps/server/package.json ./apps/server/package.json
# CMD node -e "fetch('http://127.0.0.1:'+(process.env.PORT||3002)+'/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
EXPOSE 3002
CMD ["pnpm","exec", "node", "--env-file=apps/server/dist/.env", "apps/server/dist/index.js"]
#CMD ["pnpm","exec", "node", "--env-file=apps/server/dist/.env", "apps/server/dist/index.js"]
CMD ["pnpm","exec", "node", "apps/server/dist/index.js"]

View File

@ -1,6 +1,6 @@
NODE_ENV=development
HOST=0.0.0.0
PORT=3002
SERVER_PORT=3002
FRONTEND_URL=http://localhost:5173

View File

@ -3,7 +3,7 @@
# ───────────────────────────────
NODE_ENV=development
HOST=0.0.0.0
PORT=3002
SERVER_PORT=3002
# URL pública del frontend (CORS).
# En dev se puede permitir todo con '*'

View File

@ -1,9 +1,22 @@
COMPANY=rodax
DOMAIN=rodax.factuges.rodax-software.local
WEB_VERSION=v0.0.1-20251031-200910
API_IMAGE=factuges-server:rodax-v0.0.1
API_PORT=3002
DB_USER=rodax_usr
DB_PASS=supersecret
DB_NAME=rodax_db
DB_ROOT_PASS=verysecret
TRAEFIK_ENTRYPOINT=web
NODE_ENV=production
HOST=0.0.0.0
PORT=3002
FRONTEND_URL=http://factuges.rodax-software.local
DB_DIALECT=mysql
DB_HOST=localhost
DB_PORT=3306

View File

@ -1,12 +1,12 @@
{
"name": "@erp/factuges-server",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"scripts": {
"build": "tsup src/index.ts --config tsup.config.ts",
"start": "NODE_ENV=production node --env-file=.env.production dist/index.js",
"dev": "tsx watch src/index.ts",
"clean": "rimraf .turbo node_modules dist",
"start": "NODE_ENV=production node dist/index.js",
"typecheck": "tsc --noEmit",
"lint": "biome lint --fix",
"format": "biome format --write"

View File

@ -9,7 +9,7 @@ import { logger } from "./lib/logger";
export function createApp(): Application {
const app = express();
app.set("port", process.env.PORT ?? 3002);
app.set("port", process.env.SERVER_PORT ?? 3002);
// Oculta la cabecera x-powered-by
app.disable("x-powered-by");

View File

@ -13,7 +13,7 @@ const isProd = NODE_ENV === "production";
const isDev = NODE_ENV === "development";
const HOST = process.env.HOST ?? "0.0.0.0";
const PORT = asNumber(process.env.PORT, 3002);
const SERVER_PORT = asNumber(process.env.SERVER_PORT, 3002);
// En producción exigimos FRONTEND_URL definido (según requisitos actuales).
const FRONTEND_URL = isProd
@ -23,9 +23,9 @@ const FRONTEND_URL = isProd
// Base de datos (dos modos: URL o parámetros sueltos)
const DATABASE_URL = process.env.DATABASE_URL; // p.ej. postgres://user:pass@host:5432/dbname
const DB_DIALECT = (process.env.DB_DIALECT as DbDialect | undefined) ?? undefined;
const DB_DIALECT = (process.env.DB_DIALECT as DbDialect | undefined) ?? "mysql";
const DB_HOST = process.env.DB_HOST ?? "localhost";
const DB_PORT = asNumber(process.env.DB_PORT, 5432);
const DB_PORT = asNumber(process.env.DB_PORT, 3306);
const DB_NAME = process.env.DB_NAME ?? "";
const DB_USER = process.env.DB_USER ?? "";
const DB_PASSWORD = process.env.DB_PASSWORD ?? "";
@ -45,7 +45,7 @@ const TRUST_PROXY = asNumber(process.env.TRUST_PROXY, 0);
export const ENV = {
NODE_ENV,
HOST,
PORT,
SERVER_PORT,
FRONTEND_URL,
DATABASE_URL,
DB_DIALECT,

View File

@ -19,7 +19,7 @@ export const currentState = {
launchedAt: DateTime.now(),
appPath: process.cwd(),
host: ENV.HOST,
port: ENV.PORT,
port: ENV.SERVER_PORT,
environment: ENV.NODE_ENV,
connections: {} as Record<string, unknown>,
};
@ -90,11 +90,11 @@ const serverError = (error: NodeJS.ErrnoException) => {
label: "serverError0",
error,
host: ENV.HOST,
port: ENV.PORT,
port: ENV.SERVER_PORT,
});
if (error.code === "EADDRINUSE") {
logger.error(`Port ${ENV.PORT} already in use`, { error, label: "serverError1" });
logger.error(`Port ${ENV.SERVER_PORT} already in use`, { error, label: "serverError1" });
} else {
logger.error(error.message, { error, label: "serverError2" });
}
@ -213,7 +213,7 @@ process.on("uncaughtException", async (error: Error) => {
// Mostrar variables de entorno
logger.info(`Environment: ${currentState.environment}`);
logger.info(`HOST: ${ENV.HOST}`);
logger.info(`PORT: ${ENV.PORT}`);
logger.info(`SERVER_PORT: ${ENV.SERVER_PORT}`);
logger.info(`API_BASE_PATH: ${API_BASE_PATH}`);
logger.info(`FRONTEND_URL: ${ENV.FRONTEND_URL}`);

View File

@ -1,7 +1,7 @@
{
"name": "@erp/factuges-web",
"private": true,
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"scripts": {
"dev": "vite --host --clearScreen false",

View File

@ -1,6 +1,6 @@
{
"name": "@erp/auth",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"type": "module",
"sideEffects": false,

View File

@ -1,6 +1,6 @@
{
"name": "@erp/core",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"type": "module",
"sideEffects": false,

View File

@ -1,6 +1,6 @@
{
"name": "@erp/customer-invoices",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"type": "module",
"sideEffects": false,

View File

@ -1,6 +1,6 @@
{
"name": "@erp/customers",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"type": "module",
"sideEffects": false,

View File

@ -1,6 +1,6 @@
{
"name": "@erp/doc-numbering",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"type": "module",
"sideEffects": false,

View File

@ -1,6 +1,6 @@
{
"name": "@erp/verifactu",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"type": "module",
"sideEffects": false,

View File

@ -1,6 +1,6 @@
{
"name": "@repo/rdx-criteria",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"type": "module",
"sideEffects": false,

View File

@ -1,6 +1,6 @@
{
"name": "@repo/rdx-ddd",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"type": "module",
"sideEffects": false,

View File

@ -1,6 +1,6 @@
{
"name": "@repo/rdx-logger",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"type": "module",
"sideEffects": false,

View File

@ -1,6 +1,6 @@
{
"name": "@repo/rdx-utils",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"type": "module",
"sideEffects": false,

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_VERSION="1.0.3"
SCRIPT_VERSION="1.0.4"
# =====================================================
# FACTUGES Build Script