FROM node:22-alpine as nodebuild

WORKDIR /ui

COPY qa/ui/ .

RUN npm install --network-timeout=100000 && \
    npm run build


FROM golang:1-alpine as gobuild

RUN apk add --no-cache git

WORKDIR /go/src/srs.epita.fr/fic-server/

COPY go.mod go.sum ./
COPY settings settings/
COPY libfic ./libfic/
COPY --from=nodebuild /ui ./qa/ui
COPY qa ./qa/
COPY admin ./admin/

RUN go get -d -v ./qa && \
    go build -v -buildvcs=false -o qa/qa ./qa


FROM alpine:3.20

EXPOSE 8083

WORKDIR /srv

ENTRYPOINT ["/srv/qa", "--bind=:8083"]

VOLUME /srv/htdocs-qa/

COPY --from=gobuild /go/src/srs.epita.fr/fic-server/qa/qa /srv/qa
