Dockers
This commit is contained in:
parent
cecba33ebb
commit
fc952b948e
20
Dockerfile
20
Dockerfile
@ -30,20 +30,7 @@ COPY modules ./modules
|
|||||||
RUN npx --yes turbo@2.5.8 prune @erp/factuges-server --docker
|
RUN npx --yes turbo@2.5.8 prune @erp/factuges-server --docker
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# 2) Instalar deps de la parte pruned (usando pnpm fetch para cache)
|
# 2) Builder: código + link deps y build
|
||||||
########################
|
|
||||||
#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
|
|
||||||
########################
|
########################
|
||||||
FROM base AS builder
|
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...
|
RUN pnpm -w turbo run build --filter=@erp/factuges-server...
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# 4) Runner minimal
|
# 3) Runner minimal
|
||||||
########################
|
########################
|
||||||
#FROM ${NODE_IMAGE} AS runner
|
#FROM ${NODE_IMAGE} AS runner
|
||||||
FROM base 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))"
|
# 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
|
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"]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
HOST=0.0.0.0
|
HOST=0.0.0.0
|
||||||
PORT=3002
|
SERVER_PORT=3002
|
||||||
FRONTEND_URL=http://localhost:5173
|
FRONTEND_URL=http://localhost:5173
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# ───────────────────────────────
|
# ───────────────────────────────
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
HOST=0.0.0.0
|
HOST=0.0.0.0
|
||||||
PORT=3002
|
SERVER_PORT=3002
|
||||||
|
|
||||||
# URL pública del frontend (CORS).
|
# URL pública del frontend (CORS).
|
||||||
# En dev se puede permitir todo con '*'
|
# En dev se puede permitir todo con '*'
|
||||||
|
|||||||
@ -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
|
NODE_ENV=production
|
||||||
HOST=0.0.0.0
|
HOST=0.0.0.0
|
||||||
PORT=3002
|
PORT=3002
|
||||||
FRONTEND_URL=http://factuges.rodax-software.local
|
FRONTEND_URL=http://factuges.rodax-software.local
|
||||||
|
|
||||||
|
|
||||||
DB_DIALECT=mysql
|
DB_DIALECT=mysql
|
||||||
DB_HOST=localhost
|
DB_HOST=localhost
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@erp/factuges-server",
|
"name": "@erp/factuges-server",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup src/index.ts --config tsup.config.ts",
|
"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",
|
"dev": "tsx watch src/index.ts",
|
||||||
"clean": "rimraf .turbo node_modules dist",
|
"clean": "rimraf .turbo node_modules dist",
|
||||||
"start": "NODE_ENV=production node dist/index.js",
|
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"lint": "biome lint --fix",
|
"lint": "biome lint --fix",
|
||||||
"format": "biome format --write"
|
"format": "biome format --write"
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import { logger } from "./lib/logger";
|
|||||||
|
|
||||||
export function createApp(): Application {
|
export function createApp(): Application {
|
||||||
const app = express();
|
const app = express();
|
||||||
app.set("port", process.env.PORT ?? 3002);
|
app.set("port", process.env.SERVER_PORT ?? 3002);
|
||||||
|
|
||||||
// Oculta la cabecera x-powered-by
|
// Oculta la cabecera x-powered-by
|
||||||
app.disable("x-powered-by");
|
app.disable("x-powered-by");
|
||||||
|
|||||||
@ -13,7 +13,7 @@ const isProd = NODE_ENV === "production";
|
|||||||
const isDev = NODE_ENV === "development";
|
const isDev = NODE_ENV === "development";
|
||||||
|
|
||||||
const HOST = process.env.HOST ?? "0.0.0.0";
|
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).
|
// En producción exigimos FRONTEND_URL definido (según requisitos actuales).
|
||||||
const FRONTEND_URL = isProd
|
const FRONTEND_URL = isProd
|
||||||
@ -23,9 +23,9 @@ const FRONTEND_URL = isProd
|
|||||||
// Base de datos (dos modos: URL o parámetros sueltos)
|
// 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 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_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_NAME = process.env.DB_NAME ?? "";
|
||||||
const DB_USER = process.env.DB_USER ?? "";
|
const DB_USER = process.env.DB_USER ?? "";
|
||||||
const DB_PASSWORD = process.env.DB_PASSWORD ?? "";
|
const DB_PASSWORD = process.env.DB_PASSWORD ?? "";
|
||||||
@ -45,7 +45,7 @@ const TRUST_PROXY = asNumber(process.env.TRUST_PROXY, 0);
|
|||||||
export const ENV = {
|
export const ENV = {
|
||||||
NODE_ENV,
|
NODE_ENV,
|
||||||
HOST,
|
HOST,
|
||||||
PORT,
|
SERVER_PORT,
|
||||||
FRONTEND_URL,
|
FRONTEND_URL,
|
||||||
DATABASE_URL,
|
DATABASE_URL,
|
||||||
DB_DIALECT,
|
DB_DIALECT,
|
||||||
|
|||||||
@ -19,7 +19,7 @@ export const currentState = {
|
|||||||
launchedAt: DateTime.now(),
|
launchedAt: DateTime.now(),
|
||||||
appPath: process.cwd(),
|
appPath: process.cwd(),
|
||||||
host: ENV.HOST,
|
host: ENV.HOST,
|
||||||
port: ENV.PORT,
|
port: ENV.SERVER_PORT,
|
||||||
environment: ENV.NODE_ENV,
|
environment: ENV.NODE_ENV,
|
||||||
connections: {} as Record<string, unknown>,
|
connections: {} as Record<string, unknown>,
|
||||||
};
|
};
|
||||||
@ -90,11 +90,11 @@ const serverError = (error: NodeJS.ErrnoException) => {
|
|||||||
label: "serverError0",
|
label: "serverError0",
|
||||||
error,
|
error,
|
||||||
host: ENV.HOST,
|
host: ENV.HOST,
|
||||||
port: ENV.PORT,
|
port: ENV.SERVER_PORT,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error.code === "EADDRINUSE") {
|
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 {
|
} else {
|
||||||
logger.error(error.message, { error, label: "serverError2" });
|
logger.error(error.message, { error, label: "serverError2" });
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ process.on("uncaughtException", async (error: Error) => {
|
|||||||
// Mostrar variables de entorno
|
// Mostrar variables de entorno
|
||||||
logger.info(`Environment: ${currentState.environment}`);
|
logger.info(`Environment: ${currentState.environment}`);
|
||||||
logger.info(`HOST: ${ENV.HOST}`);
|
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(`API_BASE_PATH: ${API_BASE_PATH}`);
|
||||||
|
|
||||||
logger.info(`FRONTEND_URL: ${ENV.FRONTEND_URL}`);
|
logger.info(`FRONTEND_URL: ${ENV.FRONTEND_URL}`);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@erp/factuges-web",
|
"name": "@erp/factuges-web",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --host --clearScreen false",
|
"dev": "vite --host --clearScreen false",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@erp/auth",
|
"name": "@erp/auth",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@erp/core",
|
"name": "@erp/core",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@erp/customer-invoices",
|
"name": "@erp/customer-invoices",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@erp/customers",
|
"name": "@erp/customers",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@erp/doc-numbering",
|
"name": "@erp/doc-numbering",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@erp/verifactu",
|
"name": "@erp/verifactu",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@repo/rdx-criteria",
|
"name": "@repo/rdx-criteria",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@repo/rdx-ddd",
|
"name": "@repo/rdx-ddd",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@repo/rdx-logger",
|
"name": "@repo/rdx-logger",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@repo/rdx-utils",
|
"name": "@repo/rdx-utils",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SCRIPT_VERSION="1.0.3"
|
SCRIPT_VERSION="1.0.4"
|
||||||
|
|
||||||
# =====================================================
|
# =====================================================
|
||||||
# FACTUGES Build Script
|
# FACTUGES Build Script
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user