ARG DOCKER_GID=565
FROM cypress/included:8.7.0

ARG DOCKER_GID
ARG angular_env=localhost
ENV ANGULAR_ENV=${angular_env}

USER root

ENV XTERM xterm
#Install packages
RUN apt-get update && \
    apt-get install --no-install-recommends -y \
    zsh jq rsync zip git npm python3 python3-pip &&\
    pip3 install awscli &&\
    apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
    userdel -f node &&\
    adduser jenkins --uid 1000 --shell /bin/sh &&\
    addgroup docker --gid ${DOCKER_GID} && \
    usermod -g docker jenkins && \
    usermod -a -G docker jenkins && \
    npm cache clean -f && \
    npm install -g n && \
    n 18.16.0

WORKDIR /app
COPY ./package*json /app/
RUN mkdir /app/nx && chown -R jenkins:docker /app && chmod -R 775 /app

RUN chown -R jenkins /app
USER jenkins
RUN npm install --legacy-peer-deps --ignore-scripts && rm -rf package*json node_modules

ENV CYPRESS_CACHE_FOLDER=/tmp

EXPOSE 4200

ENTRYPOINT []

# start normally
CMD ["/bin/zsh", "-c", "tail", "-f", "/dev/null"]
