-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
prod.Dockerfile
a multistage build
- Loading branch information
Showing
2 changed files
with
32 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,45 @@ | ||
FROM ruby:2.6.6-alpine3.12 | ||
FROM ruby:2.6.6-alpine3.12 as builder | ||
|
||
ENV BUNDLER_VERSION=2.1.4 | ||
ENV RAILS_ENV=production | ||
ENV NODE_ENV=production | ||
ENV RAILS_ENV=development | ||
ENV NODE_ENV=development | ||
|
||
RUN apk --update --no-cache add \ | ||
build-base \ | ||
git \ | ||
linux-headers \ | ||
postgresql-dev \ | ||
nodejs yarn \ | ||
tzdata \ | ||
imagemagick file | ||
tzdata | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
RUN chmod +x bin/* \ | ||
&& gem install bundler:2.1.4 \ | ||
&& bundle install \ | ||
--jobs "$(nproc)" \ | ||
--without development test \ | ||
&& yarn install --pure-lockfile \ | ||
&& rails assets:precompile | ||
|
||
|
||
WORKDIR /pfadiolten-home | ||
COPY Gemfile . | ||
COPY Gemfile.lock . | ||
COPY package.json . | ||
COPY yarn.lock . | ||
FROM ruby:2.6.6-alpine3.12 | ||
|
||
RUN gem install bundler:2.1.4 \ | ||
&& bundle install --quiet --jobs 4 \ | ||
&& yarn install --silent --pure-lockfile | ||
ENV BUNDLER_VERSION=2.1.4 | ||
ENV RAILS_ENV=production | ||
ENV NODE_ENV=production | ||
|
||
RUN apk --update --no-cache add \ | ||
libpq \ | ||
tzdata \ | ||
imagemagick file | ||
|
||
COPY . /pfadiolten-home | ||
WORKDIR /app | ||
COPY . . | ||
COPY --from=builder /usr/local/bundle /usr/local/bundle | ||
COPY --from=builder /app/public/assets /app/public/assets | ||
COPY --from=builder /app/public/packs /app/public/packs | ||
|
||
RUN chmod +x bin/* | ||
CMD ["bin/rails", "server", "-b", "0.0.0.0"] | ||
|
||
CMD ["bin/rails", "server", "-b", "0.0.0.0"] |
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