# syntax=docker/dockerfile:1.7
FROM --platform=linux/amd64 node:22-alpine AS build
WORKDIR /workspace

COPY package.json ./package.json
COPY yarn.lock ./yarn.lock
COPY ops-platform ./ops-platform

ENV YARN_CACHE_FOLDER=/var/cache/yarn

RUN --mount=type=cache,target=/var/cache/yarn,sharing=locked \
    yarn install --frozen-lockfile

ARG OPS_APP_BASE=/
ARG OPS_API_BASE_URL=/api

RUN cd ops-platform && \
    VITE_APP_BASE=${OPS_APP_BASE} \
    VITE_API_BASE_URL=${OPS_API_BASE_URL} \
    yarn build

FROM --platform=linux/amd64 nginx:1.27-alpine

COPY nginx/ops.conf /etc/nginx/conf.d/default.conf
COPY --from=build /workspace/ops-platform/dist /usr/share/nginx/html

EXPOSE 80
