diff --git a/.env.example b/.env.example index d5fbb2ef..aeb79f50 100644 --- a/.env.example +++ b/.env.example @@ -35,6 +35,9 @@ export SECRET_KEY_BASE=insecure_key_for_dev export RAILS_ENV=development export NODE_ENV=development +# Where should gems be installed +export BUNDLE_PATH=/app/vendor/bundle + # The bind port for puma. # # Be warned that if you change this value you'll need to change 8000 in both diff --git a/.gitignore b/.gitignore index 4781fe47..3d6a9302 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ yarn-debug.log* .env* !.env.example docker-compose.override.yml +vendor/bundle diff --git a/Dockerfile b/Dockerfile index 3a78799b..e5b124d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,9 +20,6 @@ RUN bash -c "set -o pipefail && apt-get update \ USER ruby -COPY --chown=ruby:ruby Gemfile* ./ -RUN bundle install - COPY --chown=ruby:ruby package.json *yarn* ./ RUN yarn install @@ -68,7 +65,6 @@ ENV RAILS_ENV="${RAILS_ENV}" \ PATH="${PATH}:/home/ruby/.local/bin" \ USER="ruby" -COPY --chown=ruby:ruby --from=assets /usr/local/bundle /usr/local/bundle COPY --chown=ruby:ruby --from=assets /app/public /public COPY --chown=ruby:ruby . . @@ -76,4 +72,4 @@ ENTRYPOINT ["/app/bin/docker-entrypoint-web"] EXPOSE 8000 -CMD ["rails", "s"] +CMD ["bundle", "exec", "rails", "s"] diff --git a/bin/docker-entrypoint-web b/bin/docker-entrypoint-web index ae406368..2125f01a 100755 --- a/bin/docker-entrypoint-web +++ b/bin/docker-entrypoint-web @@ -21,4 +21,12 @@ if compgen -G "${manifest_files}" > /dev/null 2>&1; then -delete fi +if bundle check +then + echo "Bundle installing..." + bundle install --jobs="$(nproc)" > ${BUNDLE_PATH}/bundle_install + tail -n 2 ${BUNDLE_PATH}/bundle_install +else + bundle install --jobs=$(nproc) +fi exec "$@" diff --git a/docker-compose.yml b/docker-compose.yml index 071a7030..e685de6d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,6 +21,7 @@ x-app: &default-app tty: true volumes: - "${DOCKER_WEB_VOLUME:-./public:/app/public}" + - "${DOCKER_BUNDLE_VOLUME:-./vendor/bundle:/app/vendor/bundle}" x-assets: &default-assets build: @@ -39,6 +40,8 @@ x-assets: &default-assets tty: true volumes: - ".:/app" + - "${DOCKER_BUNDLE_VOLUME:-./vendor/bundle:/app/vendor/bundle}" + services: postgres: @@ -101,7 +104,7 @@ services: cable: <<: *default-app - command: "puma -p 28080 cable/config.ru" + command: "bundle exec puma -p 28080 cable/config.ru" entrypoint: [] deploy: resources: