FROM ruby:3.0-alpine
LABEL maintainer="Justin Collins"

WORKDIR /usr/src/app

# Create user named app with uid=9000, give it ownership of /usr/src/app
RUN adduser -u 9000 -D app && \
    chown -R app:app /usr/src/app
USER app

# Copy our Gemfile (and related files) *without* copying our actual source code yet
COPY Gemfile* *.gemspec gem_common.rb ./
# Copy lib/brakeman/version.rb so that bundle install works
COPY lib/brakeman/version.rb ./lib/brakeman/

# Install the necessary gems
RUN bundle install --jobs 4 --without "development test"

# Copy in the latest Brakeman source code as the final stage
COPY . /usr/src/app

# Default to looking for source in /code
WORKDIR /code

CMD ["/usr/src/app/bin/codeclimate-brakeman"]
