FROM almalinux:8

# Instalar Node.js 10 y dependencias del sistema para Puppeteer/jsreport
RUN dnf -y install curl tzdata && \
    curl -fsSL https://rpm.nodesource.com/setup_10.x | bash - && \
    dnf install -y nodejs \
    gtk3 \   
    libX11-xcb \
    libXcomposite \
    libXdamage \
    libXrandr \
    libXScrnSaver \         
    libXext \
    libXfixes \
    libXrender \
    libXtst \
    libXcursor \ 
    at-spi2-atk \
    nss \
    atk \
    cups-libs \
    dbus-libs \
    pango \
    cairo \
    gdk-pixbuf2 \
    alsa-lib \
    liberation-fonts \
    xdg-utils \
    libdrm \
    mesa-libgbm \
    --setopt=install_weak_deps=False \
    --skip-broken && \
    dnf clean all

# Instalar jsreport CLI globalmente
RUN npm install -g jsreport-cli

WORKDIR /app

COPY package*.json ./
# Instalamos ignorando errores menores por la antigüedad de Node 10
RUN npm install || true

COPY . .

EXPOSE 5488

CMD ["node", "server.js"]