Created
January 29, 2022 13:00
-
-
Save empeje/0d8afc3b519f4bc13f79ddb8c32218b9 to your computer and use it in GitHub Desktop.
Dockerfile named-multi-staged (one Dockerfile to rule them all!)
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 Layer started | |
FROM ruby:3.0.1 as base | |
WORKDIR /app | |
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \ | |
apt-get install -y nodejs libsodium-dev && \ | |
npm i -g yarn | |
COPY Gemfile Gemfile.lock ./ | |
# === Development Layer started | |
FROM base as dev | |
RUN apt-get install -y postgresql-client | |
RUN bundle install && yarn | |
# === Builder Layer started | |
FROM base | |
RUN bundle config set --local without 'development test' && \ | |
bundle install -j4 --no-cache | |
COPY . . | |
# === Runtime Layer started | |
FROM ruby:3.0.1 | |
WORKDIR /app | |
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \ | |
apt-get install -y nodejs && \ | |
npm i -g yarn | |
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ | |
COPY --from=builder /app/ /app/ | |
CMD bin/rake assets:precompile && bin/rails server -p ${PORT:-5000} -e $RAILS_ENV |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment