Skip to content

Instantly share code, notes, and snippets.

@TsubasaKawajiri
Last active December 21, 2021 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TsubasaKawajiri/511151ebfe1b8a5bbe3dcaf22b74c133 to your computer and use it in GitHub Desktop.
Save TsubasaKawajiri/511151ebfe1b8a5bbe3dcaf22b74c133 to your computer and use it in GitHub Desktop.
FROM ruby:[RUBY_VERSION]-alpine[ALPINE_VERSION] AS builder
RUN apk update && \
apk add --no-cache tzdata curl-dev g++ make git nodejs yarn mariadb-dev[if MYSQL]
WORKDIR /builder
COPY . /builder
COPY ./Gemfile ./Gemfile.lock ./package.json ./yarn.lock ./
RUN gem install bundler && \
bundle config set without 'development test' && \
bundle config set no-cache 'true' && \
bundle install -j8 && \
find /usr/local/bundle -path 'gems/*/ext/*/Makefile' -exec dirname {} \; | xargs -n1 -P$(nproc) -I{} make -C {} clean && \
rm -rf /usr/local/bundle/cache
RUN rails assets:precompile RAILS_ENV=[RAILS_ENV] SECRET_KEY_BASE=[SECRET_KEY_BASE]
FROM ruby:[RUBY_VERSION]-alpine[ALPINE_VERSION] AS application
RUN apk update --no-cache && \
apk add --no-cache tzdata mariadb-dev[if MYSQL]
WORKDIR /app
COPY . /app
COPY --from=builder /builder/public /app/public
COPY --from=builder /usr/local/bundle /usr/local/bundle
ENV LANG=C.UTF-8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment