From 70112007e758551aaf9ec643420ebd400c654e04 Mon Sep 17 00:00:00 2001 From: Kevin Dew Date: Thu, 12 Nov 2020 11:36:14 +0000 Subject: [PATCH 1/2] Set Dockerfile to RAILS_ENV of production This dockerfile is only intended to run the app in a RAILS_ENV of production (only production dependencies are installed) so setting this to a default of development is a bit misleading. --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index cc406b3e7..5b9bf87f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,10 @@ FROM ruby:2.7.2 RUN apt-get update -qq && apt-get upgrade -y && apt-get install -y build-essential nodejs && apt-get clean RUN gem install foreman +# This image is only intended to be able to run this app in a production RAILS_ENV +ENV RAILS_ENV production + ENV GOVUK_APP_NAME static -ENV RAILS_ENV development ENV REDIS_URL redis://redis ENV PORT 3013 @@ -17,6 +19,6 @@ RUN bundle install ADD . $APP_HOME -RUN GOVUK_WEBSITE_ROOT=https://www.gov.uk GOVUK_APP_DOMAIN=www.gov.uk RAILS_ENV=production bundle exec rails assets:precompile +RUN GOVUK_WEBSITE_ROOT=https://www.gov.uk GOVUK_APP_DOMAIN=www.gov.uk bundle exec rails assets:precompile CMD foreman run web From 45a3115e1c31b38023756ed72bec6936ba875713 Mon Sep 17 00:00:00 2001 From: Kevin Dew Date: Thu, 12 Nov 2020 11:37:28 +0000 Subject: [PATCH 2/2] Configure gem install for production This speeds up gem install, is configured for deployment and doesn't install dev and test gems. This reflects that this Dockerfile is intended for running the app in a production environment. --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5b9bf87f1..a58924089 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,9 @@ RUN mkdir $APP_HOME WORKDIR $APP_HOME ADD .ruby-version $APP_HOME/ ADD Gemfile* $APP_HOME/ -RUN bundle install +RUN bundle config set deployment 'true' +RUN bundle config set without 'development test' +RUN bundle install --jobs 4 ADD . $APP_HOME