FROM node:22-alpine AS base
WORKDIR /app/frontend
COPY package.json yarn.lock ./
RUN yarn install
COPY . .

FROM base AS build
RUN yarn build

FROM base AS develop
EXPOSE 5173
ENTRYPOINT [ "yarn", "dev", "--host", "0.0.0.0" ]

FROM nginx:alpine AS production
COPY --from=build /app/frontend/dist/ /usr/share/nginx/html
ENTRYPOINT [ "nginx", "-g", "daemon off;" ]
