# Multi-arch: funciona en ARM64 (Oracle Ampere) i AMD64
FROM node:20-alpine

WORKDIR /app

# pg (node-postgres) és pur JS — no cal compilació nativa
COPY package*.json ./
RUN npm install --omit=dev --no-audit --no-fund

COPY server.js ./

# Els fitxers estàtics (index.html, comarca-paths.js) es munten com a volum
# en /app/public/ — no s'inclouen a la imatge per facilitar actualitzacions.
RUN mkdir -p /app/public

EXPOSE 3003

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s \
  CMD wget -qO- http://localhost:3003/api/health || exit 1

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