Skip to content

Put gems in host 'vendor/bundle' #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
9 changes: 9 additions & 0 deletions bin/docker-entrypoint-web
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ if compgen -G "${manifest_files}" > /dev/null 2>&1; then
-delete
fi

if bundle check
then
# Don't print a huge long list of gems if they are already installed
echo "Bundle installing silently..."
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