David Kimura PRO said almost 2 years ago on In Depth with Docker Compose :
If anyone is wanting to use an Alpine version of a Ruby image, here's what I'm using. I've included some commented out lines which you can replace the postgresql-dev with the sqlite or mysql (mariadb) depending on the database you're using.

FROM ruby:2.6.6-alpine3.12
LABEL [email protected]

# sqlite-dev \
# mariadb-dev \
RUN apk add --no-cache --update build-base \
  git \
  postgresql-dev \
  nodejs \
  yarn \
  tzdata \
  && rm -rf /var/cache/apk/*

RUN bundle config --global frozen 1

COPY Gemfile Gemfile.lock ./
RUN gem update --system
RUN gem install bundler
RUN bundle install -j $(nproc)

RUN mkdir -p /app

This helped reduce the base image from 2GB to 1GB.