# ── Subscribe Service ────────────────────────────────────────────────────
# Keep In Touch — subscribe capture endpoint for Tree of Ascension docs.
#
# Deploy on Coolify:
#   1. Point the service to this repo (or a subfolder if supported)
#   2. Set Build Pack: Dockerfile
#   3. Add a persistent volume at /app/data
#   4. Set env vars (PORT, ALLOW_ORIGIN, ADMIN_TOKEN)
#   5. Map your domain (e.g. subscribe.krystl.org)

FROM node:22-alpine

# Create unprivileged user
RUN addgroup -S app && adduser -S -G app app

WORKDIR /app

# Dependencies first for layer caching
COPY package.json ./
RUN npm install --omit=dev && npm cache clean --force

# Application
COPY server.js ./

# Persistent data volume + ownership
RUN mkdir -p /app/data && chown -R app:app /app

USER app

EXPOSE 8080
ENV PORT=8080

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