FROM node:24-alpine

WORKDIR /app

ENV NODE_ENV=production
ENV APP_PORT=8787

COPY package.json ./
COPY index.html styles.css game.js server.js ./

EXPOSE 8787

HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD node -e "fetch('http://127.0.0.1:' + (process.env.APP_PORT || 8787) + '/healthz').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"

USER node

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