|
|
@@ -1,5 +1,8 @@
|
|
|
FROM ruby:2.6.3-alpine AS base
|
|
|
|
|
|
+ARG BUNDLE_JOBS=${nproc}
|
|
|
+ARG BUNDLE_RETRY=5
|
|
|
+
|
|
|
ARG BUILD_PACKAGES="build-base git"
|
|
|
ARG DEV_PACKAGES="postgresql-dev yarn"
|
|
|
ARG RUBY_PACKAGES="tzdata"
|
|
|
@@ -16,33 +19,33 @@ FROM base AS builder
|
|
|
# Copying the Gemfile separately allows the image to be cached.
|
|
|
# These steps are not rerun unless the Gemfile or Gemfile.lock is changed.
|
|
|
COPY Gemfile Gemfile.lock /app/
|
|
|
-RUN bundle install --jobs 4 --retry 5
|
|
|
+RUN BUNDLE_JOBS=$BUNDLE_JOBS BUNDLE_RETRY=$BUNDLE_RETRY bundle install
|
|
|
|
|
|
# Again, copy seperately so we can cache this step.
|
|
|
+# There is no "--no-cache" option like NPM, and won't make sense to add one with
|
|
|
+# upcoming yarn versions: https://github.com/yarnpkg/rfcs/pull/53
|
|
|
COPY package.json yarn.lock /app/
|
|
|
RUN yarn install && yarn cache clean
|
|
|
|
|
|
# Copy our app over now
|
|
|
COPY bin/ /app/bin
|
|
|
-COPY .rspec Rakefile /app/
|
|
|
+COPY .rspec Rakefile .ruby-version /app/
|
|
|
COPY vendor/ /app/vendor
|
|
|
COPY config.ru /app/config.ru
|
|
|
COPY config/ /app/config
|
|
|
COPY config/database.yml.docker /app/config/database.yml
|
|
|
COPY public/ /app/public
|
|
|
+COPY storage/ /app/storage
|
|
|
+COPY lib/ /app/lib
|
|
|
COPY db/ /app/db
|
|
|
COPY app/assets/ /app/app/assets
|
|
|
COPY app/javascript/ /app/app/javascript
|
|
|
-COPY lib/ /app/lib
|
|
|
|
|
|
# Compile our assets, moving unneeded directories out of way for the prod image
|
|
|
# after compilation has completed.
|
|
|
-RUN rails assets:precompile --trace && \
|
|
|
- rm -rf tmp/cache log && \
|
|
|
+RUN rm -rf tmp/cache log && \
|
|
|
mkdir -p /var/cache/app/app && \
|
|
|
- mv node_modules /var/cache/app && \
|
|
|
- mv app/assets /var/cache/app/app && \
|
|
|
- mv app/javascript /var/cache/app/app
|
|
|
+ mv node_modules /var/cache/app
|
|
|
|
|
|
################################################################################
|
|
|
FROM base AS dev
|
|
|
@@ -50,33 +53,31 @@ FROM base AS dev
|
|
|
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
|
|
|
COPY --from=builder /app/ /app/
|
|
|
COPY --from=builder /var/cache/app/ /app/
|
|
|
-
|
|
|
-COPY app/ /app/app
|
|
|
COPY spec /app/spec
|
|
|
|
|
|
+# Watchman is required for relay-compiler to run in watch mode
|
|
|
+COPY --from=icalialabs/watchman /usr/local/bin/watchman* /usr/local/bin/
|
|
|
+RUN mkdir -p /usr/local/var/run/watchman && \
|
|
|
+ touch /usr/local/var/run/watchman/.not-empty
|
|
|
+
|
|
|
################################################################################
|
|
|
FROM base AS prod
|
|
|
|
|
|
+# FIXME: Not production ready
|
|
|
+
|
|
|
ENV RAILS_ENV=production
|
|
|
|
|
|
# Install only required gems for production, and remove any uneccesary build
|
|
|
# packages
|
|
|
-RUN bundle install --jobs 4 --retry 5 --without development test && \
|
|
|
+RUN BUNDLE_JOBS=$BUNDLE_JOBS BUNDLE_RETRY=$BUNDLE_RETRY bundle install --without development test && \
|
|
|
apk rm $BUILD_PACKAGES $DEV_PACKAGES
|
|
|
|
|
|
-COPY bin/ /app/bin
|
|
|
-COPY .rspec .ruby-version Rakefile /app/
|
|
|
-COPY vendor/ /app/vendor
|
|
|
-COPY config.ru /app/config.ru
|
|
|
-COPY config/ /app/config
|
|
|
-COPY config/database.yml.docker /app/config/database.yml
|
|
|
-COPY public/ /app/public
|
|
|
-COPY db/ /app/db
|
|
|
-COPY lib/ /app/lib
|
|
|
-COPY app/ /app/app
|
|
|
+COPY --from=builder /app/ /app/
|
|
|
|
|
|
-COPY --from=builder public/ /app/public
|
|
|
+RUN rails assets:precompile && \
|
|
|
+ rm -rf /app/app/assets && \
|
|
|
+ rm -rf /app/app/javascript
|
|
|
|
|
|
# Run the server
|
|
|
EXPOSE 3000
|
|
|
-CMD ["rails", "server", "-b", "0.0.0.0"]
|
|
|
+CMD ["rails", "server", "-p", "3000"]
|