diff --git a/Containerfile b/Containerfile index 22c2c53bc..86b679e8b 100644 --- a/Containerfile +++ b/Containerfile @@ -10,8 +10,8 @@ RUN curl -sL https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo dnf -y clean all && \ rm -rf /var/cache/yum -ENV BUNDLER_VERSION=2.1.4 BUNDLE_SILENCE_ROOT_WARNING=1 -RUN gem install bundler:"${BUNDLER_VERSION}" +ENV BUNDLER_VERSION=2.1.4 BUNDLE_SILENCE_ROOT_WARNING=true BUNDLE_SILENCE_DEPRECATIONS=true +RUN gem install -N bundler:"${BUNDLER_VERSION}" ENV APP_USER=forem APP_UID=1000 APP_GID=1000 APP_HOME=/opt/apps/forem \ LD_PRELOAD=/usr/lib64/libjemalloc.so.2 @@ -31,16 +31,15 @@ COPY ./.ruby-version "${APP_HOME}"/ COPY ./Gemfile ./Gemfile.lock "${APP_HOME}"/ COPY ./vendor/cache "${APP_HOME}"/vendor/cache -RUN bundle config build.sassc --disable-march-tune-native && \ - bundle config set deployment 'true' && \ - bundle config set without 'development test' && \ - bundle install --jobs 4 --retry 5 && \ +ENV BUNDLE_WITHOUT="development:test" +RUN bundle config --local build.sassc --disable-march-tune-native && \ + bundle install --deployment --jobs 4 --retry 5 && \ find "${APP_HOME}"/vendor/bundle -name "*.c" -delete && \ find "${APP_HOME}"/vendor/bundle -name "*.o" -delete -RUN mkdir -p "${APP_HOME}"/public/{assets,images,packs,podcasts,uploads} +COPY . "${APP_HOME}" -COPY . "${APP_HOME}"/ +RUN mkdir -p "${APP_HOME}"/public/{assets,images,packs,podcasts,uploads} RUN RAILS_ENV=production NODE_ENV=production bundle exec rake assets:precompile @@ -48,7 +47,7 @@ RUN echo $(date -u +'%Y-%m-%dT%H:%M:%SZ') >> "${APP_HOME}"/FOREM_BUILD_DATE && \ echo $(git rev-parse --short HEAD) >> "${APP_HOME}"/FOREM_BUILD_SHA && \ rm -rf "${APP_HOME}"/.git/ -RUN rm -rf node_modules app/assets vendor/assets vendor/cache spec +RUN rm -rf node_modules vendor/assets spec ## Production FROM quay.io/forem/ruby:2.7.2 as production @@ -62,7 +61,7 @@ RUN dnf install --setopt install_weak_deps=false -y bash curl ImageMagick \ && rm -rf /var/cache/yum ENV BUNDLER_VERSION=2.1.4 BUNDLE_SILENCE_ROOT_WARNING=1 -RUN gem install bundler:"${BUNDLER_VERSION}" +RUN gem install -N bundler:"${BUNDLER_VERSION}" ENV APP_USER=forem APP_UID=1000 APP_GID=1000 APP_HOME=/opt/apps/forem \ LD_PRELOAD=/usr/lib64/libjemalloc.so.2 @@ -92,7 +91,6 @@ RUN dnf install --setopt install_weak_deps=false -y \ rm -rf /var/cache/yum COPY --chown="${APP_USER}":"${APP_USER}" ./app/assets "${APP_HOME}"/app/assets -COPY --chown="${APP_USER}":"${APP_USER}" ./vendor/cache "${APP_HOME}"/vendor/cache COPY --chown="${APP_USER}":"${APP_USER}" ./spec "${APP_HOME}"/spec COPY --from=builder /usr/local/bin/dockerize /usr/local/bin/dockerize @@ -100,14 +98,12 @@ RUN chown "${APP_USER}":"${APP_USER}" -R "${APP_HOME}" USER "${APP_USER}" -RUN bundle config build.sassc --disable-march-tune-native && \ - bundle config set deployment 'false' && \ - bundle config --delete without 'development test' && \ - bundle install --jobs 4 --retry 5 && \ +RUN bundle config --local build.sassc --disable-march-tune-native && \ + bundle install --deployment --jobs 4 --retry 5 && \ find "${APP_HOME}"/vendor/bundle -name "*.c" -delete && \ find "${APP_HOME}"/vendor/bundle -name "*.o" -delete -RUN yarn install --frozen-lockfile && RAILS_ENV=test NODE_ENV=test bundle exec rails webpacker:compile +#RUN yarn install --frozen-lockfile && RAILS_ENV=test NODE_ENV=test bundle exec rails webpacker:compile ENTRYPOINT ["./scripts/entrypoint-dev.sh"] @@ -117,7 +113,6 @@ CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0", "-p", "3000"] FROM builder AS development COPY --chown="${APP_USER}":"${APP_USER}" ./app/assets "${APP_HOME}"/app/assets -COPY --chown="${APP_USER}":"${APP_USER}" ./vendor/cache "${APP_HOME}"/vendor/cache COPY --chown="${APP_USER}":"${APP_USER}" ./spec "${APP_HOME}"/spec COPY --from=builder /usr/local/bin/dockerize /usr/local/bin/dockerize @@ -125,10 +120,8 @@ RUN chown "${APP_USER}":"${APP_USER}" -R "${APP_HOME}" USER "${APP_USER}" -RUN bundle config build.sassc --disable-march-tune-native && \ - bundle config set deployment 'false' && \ - bundle config --delete without 'development test' && \ - bundle install --jobs 4 --retry 5 && \ +RUN bundle config --local build.sassc --disable-march-tune-native && \ + bundle install --deployment --jobs 4 --retry 5 && \ find "${APP_HOME}"/vendor/bundle -name "*.c" -delete && \ find "${APP_HOME}"/vendor/bundle -name "*.o" -delete diff --git a/scripts/build_containers.sh b/scripts/build_containers.sh old mode 100644 new mode 100755