ARG BUILDER_IMAGE=registry.altlinux.org/basealt/altsp:c10f1
ARG RUNTIME_IMAGE=docker.angie.software/angie:latest

FROM $BUILDER_IMAGE AS builder

ARG MVN_FLAGS="-Pprod"

RUN apt-get update \
 && apt-get -y install git glibc-locales java-17-openjdk-devel maven node \
 && apt-get clean

ENV JAVA_HOME=/usr/lib/jvm/java
ENV LANG ru_RU.UTF-8
ENV LANGUAGE ru_RU.UTF-8
ENV LC_ALL ru_RU.UTF-8

WORKDIR /app
COPY . .
RUN mkdir -p $HOME/.m2 \
 && cp config/pgs-settings.xml $HOME/.m2/settings.xml \
 && cp -f config/pgs-npmrc frontend/.npmrc \
 && mvn clean package -T4C ${MVN_FLAGS}


FROM $RUNTIME_IMAGE

COPY config/angie.conf /etc/angie/angie.conf
COPY --from=builder /app/frontend/dist /frontend
