This commit is contained in:
David Arranz 2024-09-09 11:32:11 +02:00
parent 6f1a1535f1
commit 9613dd25a1
3 changed files with 72 additions and 2 deletions

View File

@ -2,8 +2,7 @@
email soporte@rodax-software.com
auto_https disable_redirects
https_port 13001
}
@ -13,3 +12,6 @@ https://presupuestos.uecko.com:13001 {
#encode gzip # Comprime las respuestas con gzip
}
https://presupuestos.uecko.com {
reverse_proxy frontend:80
}

49
Dockerfile.client Normal file
View File

@ -0,0 +1,49 @@
# syntax=docker/dockerfile:1.4
# BUILD STAGE
FROM node:lts-iron AS builder
# Establecer el directorio de trabajo
WORKDIR /www
# Copiar los archivos de dependencias
COPY package.json .
COPY tsconfig*.json .
RUN yarn install
RUN mkdir -p ./shared
RUN mkdir -p ./client
COPY shared ./shared
COPY client ./client
#CMD pwd && ls -la
RUN cd ./shared && yarn install
RUN cd ./client && yarn install
# Ejecutar el build
# Si hay un error, mostrarlo en detalle.
RUN cd ./client && yarn run build || { echo 'Error during build'; exit 1; }
# FINAL STAGE (Producción)
FROM node:lts-iron AS prod
WORKDIR /www
# Copiar los archivos del build desde la fase anterior
COPY --from=builder /www/client/dist .
COPY --from=builder /www/client/package.json .
#COPY --from=builder /api/server/tsconfig.production.json ./tsconfig.json
# Instalar sólo las dependencias de producción en el servidor
RUN yarn install --production
# Exponer el puerto que la API usa
EXPOSE 80
#CMD pwd && ls -la
#CMD cat package.json
# Comando para correr la aplicación
#CMD node -r ts-node/register/transpile-only -r tsconfig-paths/register ./server/src/index.js

View File

@ -6,6 +6,7 @@ services:
- ./Caddyfile:/etc/caddy/Caddyfile # Monta el archivo de configuración
- caddy_data:/data # Almacena los certificados en este volumen
- caddy_config:/config # Configuración de Caddy
- caddy_srv:/srv
ports:
- 80:80 # Puerto HTTP (Caddy lo redirige automáticamente a HTTPS)
- 443:443 # Puerto HTTPS
@ -70,9 +71,27 @@ services:
condition: service_completed_successfully
restart: on-failure
frontend:
env_file: "stack.env"
build:
args:
- NODE_ENV=production
context: ./
dockerfile: Dockerfile.client
environment:
- NODE_ENV=production
ports:
- 80:80
networks:
- reverse_proxy
depends_on:
- backend
restart: on-failure
volumes:
caddy_data:
caddy_config:
caddy_srv:
mariadb_data:
backend_logs: