-
-
Save luizkowalski/7c2234aacb8ff66a3f9d3f6cc9e5e85d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG RUBY_VERSION=3.1.2 | |
ARG VARIANT=jemalloc-bullseye-slim | |
FROM quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-${VARIANT} as base | |
ARG NODE_VERSION=18 | |
ARG BUNDLER_VERSION=2.3.23 | |
ARG RAILS_ENV=production | |
ENV RAILS_ENV=${RAILS_ENV} | |
ARG PORT=8080 | |
ENV PORT=${PORT} | |
ENV RAILS_SERVE_STATIC_FILES true | |
ENV RAILS_LOG_TO_STDOUT true | |
ARG BUNDLE_WITHOUT=development:test | |
ARG BUNDLE_JOBS=4 | |
ARG BUNDLE_PATH=vendor/bundle | |
ENV BUNDLE_PATH ${BUNDLE_PATH} | |
ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT} | |
ENV BUNDLE_JOBS ${BUNDLE_JOBS} | |
RUN mkdir /app | |
WORKDIR /app | |
RUN mkdir -p tmp/pids | |
SHELL ["/bin/bash", "-c"] | |
RUN curl https://get.volta.sh | bash | |
ENV BASH_ENV ~/.bashrc | |
ENV VOLTA_HOME /root/.volta | |
ENV PATH $VOLTA_HOME/bin:/usr/local/bin:$PATH | |
RUN volta install node@${NODE_VERSION} && volta install yarn | |
FROM base as build_deps | |
ARG DEV_PACKAGES="git build-essential libpq-dev" | |
ENV DEV_PACKAGES ${DEV_PACKAGES} | |
RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt \ | |
--mount=type=cache,id=dev-apt-lib,sharing=locked,target=/var/lib/apt \ | |
apt-get update -qq && \ | |
apt-get install --no-install-recommends -y ${DEV_PACKAGES} \ | |
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives | |
FROM build_deps as gems | |
RUN gem install -N bundler -v ${BUNDLER_VERSION} | |
COPY ../Gemfile* ./ | |
COPY ../yarn.* ./ | |
COPY ../package*json ./ | |
RUN bundle install \ | |
&& find vendor/bundle/ -name ".git" -exec rm -rv {} + \ | |
&& find vendor/bundle/ -name "*.c" -delete \ | |
&& find vendor/bundle/ -name "*.o" -delete \ | |
&& find vendor/bundle/ -name "*.gem" -delete \ | |
&& rm -rf vendor/bundle/ruby/*/cache | |
FROM build_deps as node_modules | |
RUN yarn install | |
FROM base | |
ARG PROD_PACKAGES="postgresql-client dnsutils" | |
ENV PROD_PACKAGES=${PROD_PACKAGES} | |
RUN --mount=type=cache,id=prod-apt-cache,sharing=locked,target=/var/cache/apt \ | |
--mount=type=cache,id=prod-apt-lib,sharing=locked,target=/var/lib/apt \ | |
apt-get update -qq && \ | |
apt-get install --no-install-recommends -y \ | |
${PROD_PACKAGES} \ | |
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives | |
COPY --from=gems /app /app | |
COPY --from=node_modules /app/node_modules /app/node_modules | |
ARG SECRET_KEY_BASE=1 | |
ENV SECRET_KEY_BASE=${SECRET_KEY_BASE} | |
COPY ../ . | |
RUN bundle exec rails assets:precompile | |
RUN rm -rf infrastructure/ | |
CMD ${SERVER_COMMAND} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment