Skip to content

Commit

Permalink
Make prod.Dockerfile a multistage build
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-va committed Mar 10, 2024
1 parent f3acff4 commit 13a6ef5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
47 changes: 31 additions & 16 deletions build/prod.Dockerfile
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"]
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- NODE_ENV=development
- CHOKIDAR_USEPOLLING=true
- WEBPACKER_DEV_SERVER_HOST=0.0.0.0
- RAILS_LOG_TO_STDOUT=true

- PFADIOLTEN_OSM_ACCESS_TOKEN
- PFADIOLTEN_INSTAGRAM_CLIENT_ID
Expand Down

0 comments on commit 13a6ef5

Please sign in to comment.