Skip to content

Commit

Permalink
Put gems in local vendor/bundle mount
Browse files Browse the repository at this point in the history
  • Loading branch information
travisdock committed Sep 9, 2023
1 parent 9b74c7b commit b387e08
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ yarn-debug.log*
.env*
!.env.example
docker-compose.override.yml
vendor/bundle
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -68,12 +65,11 @@ 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 . .

ENTRYPOINT ["/app/bin/docker-entrypoint-web"]

EXPOSE 8000

CMD ["rails", "s"]
CMD ["bundle", "exec", "rails", "s"]
8 changes: 8 additions & 0 deletions bin/docker-entrypoint-web
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -39,6 +40,8 @@ x-assets: &default-assets
tty: true
volumes:
- ".:/app"
- "${DOCKER_BUNDLE_VOLUME:-./vendor/bundle:/app/vendor/bundle}"


services:
postgres:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit b387e08

Please sign in to comment.