# check=skip=SecretsUsedInArgOrEnv
# ===== Build Vue =====
FROM node:22 AS frontend-builder

WORKDIR /frontend
COPY wwwroot/ibms_ems/package*.json ./
RUN npm install
COPY wwwroot/ibms_ems ./
RUN npm run build

# ===== Backend =====
FROM node:22-alpine

WORKDIR /app

COPY package*.json ./
RUN npm install --production

COPY . .

# copy Vue build
COPY --from=frontend-builder /frontend/dist ./wwwroot/ibms_ems/dist

ENV NODE_ENV=production \
    PORT=8080 \ 
    APS_CLIENT_ID= \
    APS_CLIENT_SECRET=

EXPOSE 8080

CMD ["npm", "run", "start"]