FROM node:20-alpine

# Set timezone to Asia/Shanghai FIRST
# This ensures that any native modules compiled during npm install are linked correctly.
RUN apk add --no-cache tzdata
ENV TZ=Asia/Shanghai

WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install

COPY . .

# Expose API port and SMTP port
EXPOSE 5182
EXPOSE 25

# Environment variables for database connection will be passed at runtime
# ENV DB_HOST=...
# ENV DB_USER=...
# ENV DB_PASSWORD=...
# ENV DB_NAME=...

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