FROM git.jt4d.ru/jt4d/node:24-alpine AS deps

WORKDIR /app

COPY ./package.json ./yarn.lock ./

RUN yarn install --production --frozen-lockfile && yarn cache clean

FROM git.jt4d.ru/jt4d/node:24-alpine

RUN apk add --no-cache tini curl

COPY --from=deps /app/node_modules /app/node_modules

COPY ./dist /app

EXPOSE 5000
ENV PORT=5000

WORKDIR /app

HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=15s \
  CMD curl -f http://localhost:5000/api/health || exit 1

ENTRYPOINT ["/sbin/tini", "--", "node", "main.js"]
