FROM node:20-alpine

WORKDIR /usr/src/app

ENV NODE_ENV=production

RUN apk add --no-cache tini ca-certificates

COPY package*.json ./

# better-sqlite3 precisa de build tools (python/make/g++) para compilar no Alpine.
RUN apk add --no-cache --virtual .build-deps python3 make g++ && \
    npm install --omit=dev --no-audit --no-fund && \
    apk del .build-deps

COPY . .

EXPOSE 3001

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["npm", "start"]
