# node:20-slim (Debian/glibc) rather than an alpine image — better-sqlite3 has prebuilt
# binaries for glibc, so this avoids needing a full C++ build toolchain in the image
# just to compile it from source, which alpine (musl) would likely require.
FROM node:20-slim

WORKDIR /app

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

COPY . .

# These get overlaid by the named volumes in docker-compose.yml — creating them here
# just means the app has somewhere to write on the very first run before that happens.
RUN mkdir -p db uploads backups && chown -R node:node /app

USER node

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