FROM node:24-slim

# better-sqlite3 has a native addon with no prebuilt binary for this
# platform/Node combo yet — build it from source, then drop the toolchain.
RUN apt-get update -q && apt-get install -y --no-install-recommends python3 make g++ \
  && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY server/package*.json server/
RUN npm install --prefix server --omit=dev \
  && apt-get purge -y python3 make g++ && apt-get autoremove -y

COPY server/src/ server/src/
COPY index.html style.css app.js favicon.svg ./

# Do NOT copy data/ — mutable runtime volume holding the SQLite db and
# image blobs, would get clobbered on every redeploy if baked in.
ENV NODE_ENV=production
ENV PORT=3000
ENV DATA_DIR=/app/data

EXPOSE 3000

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