Created
December 27, 2021 07:58
-
-
Save ruzia/04815f21bc85bbe6383e9ebb765a88c7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
################ | |
# BASE | |
FROM ruby:3.0.3-slim AS base | |
WORKDIR /app | |
ENV RAILS_ENV production | |
ENV BUNDLE_DEPLOYMENT true | |
ENV BUNDLE_PATH vendor/bundle | |
ENV BUNDLE_WITHOUT development:test | |
# Install bundler | |
RUN gem install bundler --no-document | |
# Setup apt | |
RUN apt-get update | |
################ | |
# BUILDER BASE | |
FROM base AS builder | |
# Install build tools | |
RUN apt-get install -y \ | |
autoconf \ | |
build-essential \ | |
git | |
################ | |
# BUNDLE | |
FROM builder AS bundle | |
# Install libs | |
RUN apt-get install -y \ | |
libsqlite3-dev | |
COPY Gemfile Gemfile.lock . | |
RUN bundle install -j 4 \ | |
&& rm -rf $BUNDLE_PATH/ruby/$RUBY_VERSION/cache/* | |
################# | |
## YARN | |
#FROM builder AS yarn | |
# | |
## Install nodejs(LTS) | |
#RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ | |
# && apt-get install -y nodejs | |
# | |
## Install yarn | |
#RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ | |
# && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ | |
# && apt update \ | |
# && apt install -y yarn | |
# | |
## Install npm packages | |
#COPY package.json yarn.lock . | |
#RUN yarn install \ | |
# && yarn cache clean | |
################ | |
# ASSETS | |
FROM builder AS assets | |
COPY . . | |
COPY --from=bundle /app/vendor/bundle /app/vendor/bundle | |
#COPY --from=yarn /app/node_modules node_modules | |
# Set a dummy value to avoid errors when building docker image. | |
# refs: https://github.com/rails/rails/issues/32947 | |
RUN SECRET_KEY_BASE=dummy bin/rails assets:precompile \ | |
&& rm -rf tmp/cache/* | |
################ | |
# MAIN | |
FROM base | |
# Install packages | |
RUN apt-get install -y \ | |
imagemagick \ | |
sqlite3 \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install the Runtime Interface Client | |
RUN gem install --no-document aws_lambda_ric | |
# Copy files | |
COPY . . | |
COPY --from=bundle /app/vendor/bundle /app/vendor/bundle | |
#COPY --from=assets /app/public/assets /app/public/assets | |
#COPY --from=assets /app/public/packs /app/public/packs | |
ENTRYPOINT ["/usr/local/bundle/bin/aws_lambda_ric"] | |
CMD ["app.handler"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment