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

ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0

WORKDIR /app

RUN corepack enable

COPY package.json yarn.lock .yarnrc.yml ./
RUN yarn install --immutable && yarn cache clean

COPY ./dist /app

RUN apk add --no-cache curl

ENV NODE_ENV=production
ENV PORT=5000

EXPOSE 5000

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

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