Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Update Dockerfile with webpacker assets
Browse files Browse the repository at this point in the history
  • Loading branch information
floriandejonckheere committed May 6, 2021
1 parent 9ac4acd commit f9b12c2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ruby:3.0-alpine
MAINTAINER Florian Dejonckheere <[email protected]>
LABEL org.opencontainers.image.source https://github.com/floriandejonckheere/code-red

ENV RUNTIME_DEPS postgresql openssh
ENV RUNTIME_DEPS postgresql
ENV BUILD_DEPS build-base curl-dev git postgresql-dev cmake nodejs yarn

ENV LC_ALL en_US.UTF-8
Expand Down
27 changes: 22 additions & 5 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM ruby:3.0-alpine AS gems
FROM ruby:3.0-alpine AS ruby

WORKDIR /app/

# Install system dependencies
RUN apk add --no-cache build-base curl-dev git postgresql-dev postgresql
RUN apk add --no-cache build-base curl-dev git postgresql-dev cmake

# Install Bundler
RUN gem update --system && gem install bundler
Expand All @@ -17,22 +17,38 @@ RUN bundle config set --local without "development test" && \
bundle config set --local deployment true && \
bundle install

FROM gems AS assets
FROM ruby AS node

# Install Yarn
RUN apk add --no-cache nodejs yarn

# Install NPM dependencies
ADD package.json /app/
ADD yarn.lock /app/

RUN yarn install

FROM node AS assets

# Only add files that affect the assets:precompile task
ADD Rakefile /app/Rakefile
ADD postcss.config.js /app/postcss.config.js
ADD config/application.rb /app/config/application.rb
ADD config/boot.rb /app/config/boot.rb
ADD config/environment.rb /app/config/environment.rb
ADD config/environments/production.rb /app/config/environments/production.rb
ADD config/initializers/assets.rb /app/config/initializers/assets.rb
ADD config/locales /app/config/locales
ADD config/webpacker.yml /app/config/webpacker.yml
ADD config/webpack /app/config/webpack
ADD app/assets /app/app/assets
ADD app/javascript /app/app/javascript
ADD bin/webpack /app/bin/webpack

ARG SECRET_KEY_BASE
RUN rake assets:precompile
RUN NODE_ENV=production rake assets:precompile

FROM gems
FROM ruby

ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
Expand All @@ -55,6 +71,7 @@ ADD . /app/

# Copy assets
COPY --from=assets /app/public/assets /app/public/assets
COPY --from=assets /app/public/packs /app/public/packs

RUN mkdir -p /app/tmp/pids/
RUN chown -R $UID:$GID /app/
Expand Down

0 comments on commit f9b12c2

Please sign in to comment.