FROM public.ecr.aws/docker/library/node:24-slim AS builder

WORKDIR /app

COPY . /app

RUN apt-get update && apt-get install -y curl

RUN npm install
RUN npm run build

# 빌드 결과 확인 (디버깅용)
# RUN ls -la /app

# 타임존 설정
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime && \
    echo "Asia/Seoul" > /etc/timezone && \
    date

FROM gcr.io/distroless/nodejs24-debian12

WORKDIR /app

COPY --from=builder /etc/localtime /etc/localtime
COPY --from=builder /etc/timezone /etc/timezone
COPY --from=builder /app ./
# COPY --from=builder /app/amazon_ecs/healthcheck.js /

# ENV NODE_ENV=<BRANCH_NAME>

# EXPOSE 3000

# 애플리케이션 시작
CMD ["./dist/main.js"]
