# Politické karty – no npm dependencies, so no install step is needed.
FROM node:22-alpine

ENV NODE_ENV=production PORT=3000
WORKDIR /app

# Copy only what the server needs at runtime; files stay owned by root (read-only for the app user).
COPY package.json server.js ./
COPY public ./public

# Run as the unprivileged "node" user that ships with the image.
USER node
EXPOSE 3000

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

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