FROM node:20

ARG ORACLE_URL
ARG ORACLE_TOKEN
ARG BUILD_VERSION
ENV ORACLE_URL=$ORACLE_URL
ENV ORACLE_TOKEN=$ORACLE_TOKEN
ENV BUILD_VERSION=$BUILD_VERSION

RUN npm list -g --depth=0
RUN apt-get -y update && apt-get install -y openjdk-17-jre locales && apt-get clean
RUN mkdir -p /usr/share/man/man1/
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
    locale-gen
ENV LC_ALL en_US.UTF-8 
ENV LANG en_US.UTF-8  
ENV LANGUAGE en_US:en  

COPY oracle.local.cite.gr.crt /usr/local/share/ca-certificates/oracle.local.cite.gr.crt
RUN update-ca-certificates

# copy the package.json to install dependencies
COPY package.json ./

# Install the dependencies and make the folder
RUN npm install --legacy-peer-deps sonar-scanner --save-dev
RUN npm install --legacy-peer-deps && mkdir /src && mv ./node_modules ./src

WORKDIR /src
COPY . .
RUN npm run sonar-scanner