FROM node:22-alpine

WORKDIR /app

ENV NODE_ENV=production
ENV PORT=80
ENV DATA_DIR=/app/store

COPY package*.json ./
RUN npm install --omit=dev

COPY index.html styles.css app.js icon.svg ./
COPY data/ ./data/
COPY server/ ./server/

RUN mkdir -p /app/store

EXPOSE 80

HEALTHCHECK --interval=15s --timeout=5s --start-period=5s --retries=3 \
  CMD wget --quiet --tries=1 --spider http://127.0.0.1:80/api/health || exit 1

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