FROM ruby:2.7.5-slim-bullseye

RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get \
        -o Dpkg::Options::="--force-confnew" --allow-remove-essential --allow-change-held-packages -fuy \
        upgrade \
    && apt-get install -y --no-install-recommends \
        cmake \
        pkg-config \
        default-libmysqlclient-dev \
        nodejs \
        curl \
        git \
        ruby-dev \
        telnet \
        nano \
        build-essential \
        libpq-dev \
        shared-mime-info \
    && apt-get autoremove \
    && apt-get autoclean \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* \
    && adduser nexus --system --group -u 1000 && mkdir -p /app && chown -R nexus:nexus /app

USER nexus

WORKDIR /app
COPY --chown=nexus:nexus Gemfile Gemfile.lock ./
RUN bundle config --local build.sassc --disable-march-tune-native && gem install bundler -v 2.1 && bundle install --jobs 20 --retry 5