FROM alpine:3.14

ENV BUILD_PKGS="build-base ruby-dev libffi-dev libxml2-dev mariadb-dev sqlite-dev" \
    RUNTIME_PKGS="ruby ruby-json ruby-bigdecimal ruby-irb ruby-bundler ca-certificates mariadb-client sqlite tzdata" \
    DEVELOPMENT_PKGS="bash"

RUN apk --no-cache add $BUILD_PKGS $RUNTIME_PKGS $DEVELOPMENT_PKGS

RUN adduser -D -u 1000 -h /srv/app -s /bin/bash app
WORKDIR /srv/app
USER app

ENV BUNDLE_JOBS=4 \
  BUNDLE_PATH=/srv/app/vendor/bundle \
  GEM_PATH=/srv/app/vendor/bundle/ruby/2.7.0:$GEM_PATH \
  PATH=/srv/app/vendor/bundle/ruby/2.7.0/bin:$PATH

EXPOSE 3000

CMD ["bash"]