FROM node:18-alpine
WORKDIR /usr/src/app

# shared 모듈 복사
COPY shared/ ./shared/

COPY tksafety/api/package*.json ./
RUN npm install --omit=dev

COPY tksafety/api/ ./

RUN chown -R node:node /usr/src/app
USER node

EXPOSE 3000

HEALTHCHECK --interval=30s --timeout=3s --start-period=20s --retries=3 \
  CMD node -e "require('http').get('http://localhost:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1); })"

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