FROM ruby:<%= config %>-alpine AS builder
LABEL maintainer=“<%= config %> using RoRo”
# Add basic packages RUN apk add –no-cache \
build-base \ postgresql-dev \ git \ nodejs \ yarn \ tzdata \ file
## Set APP_HOME and BUNDLE_PATH as using ENV instructions: ENV APP_HOME /usr/src/app/ ENV BUNDLE_PATH /gems
## Create both as directories to make sure they exist: RUN mkdir -p ${APP_HOME} RUN mkdir ${BUNDLE_PATH}
## Tell Docker to create volumes for our workspace and gems ## so other containers can access them.
RUN gem install bundler:2.1.4
WORKDIR ${APP_HOME}
## Create a Gemfile with just the Rails gem inside: RUN echo -e “source 'rubygems.org’ngem 'rails', '6.1.3.1'” > Gemfile
## Bundle to install rails: RUN bundle install
## Use Rails to generate a new app. We'll configure it later. RUN bundle exec rails new . \
--database=postgresql \ --skip-bundle \ --skip-webpack-install
RUN bundle –jobs 4 RUN bundle exec rails webpacker:install RUN bundle exec rails yarn:install ## Tell docker not to create a layer: FROM scratch AS export-stage
## Copy the generated files onto the host. Note that because we are in a
## new container, we don't have access to the previous ${APP_HOME} ## variable and so we must hard code it as our source: COPY –from=builder /usr/src/app/ .