Skip to content

Commit b387e08

Browse files
committed
Put gems in local vendor/bundle mount
1 parent 9b74c7b commit b387e08

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export SECRET_KEY_BASE=insecure_key_for_dev
3535
export RAILS_ENV=development
3636
export NODE_ENV=development
3737

38+
# Where should gems be installed
39+
export BUNDLE_PATH=/app/vendor/bundle
40+
3841
# The bind port for puma.
3942
#
4043
# Be warned that if you change this value you'll need to change 8000 in both

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ yarn-debug.log*
2828
.env*
2929
!.env.example
3030
docker-compose.override.yml
31+
vendor/bundle

Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ RUN bash -c "set -o pipefail && apt-get update \
2020

2121
USER ruby
2222

23-
COPY --chown=ruby:ruby Gemfile* ./
24-
RUN bundle install
25-
2623
COPY --chown=ruby:ruby package.json *yarn* ./
2724
RUN yarn install
2825

@@ -68,12 +65,11 @@ ENV RAILS_ENV="${RAILS_ENV}" \
6865
PATH="${PATH}:/home/ruby/.local/bin" \
6966
USER="ruby"
7067

71-
COPY --chown=ruby:ruby --from=assets /usr/local/bundle /usr/local/bundle
7268
COPY --chown=ruby:ruby --from=assets /app/public /public
7369
COPY --chown=ruby:ruby . .
7470

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

7773
EXPOSE 8000
7874

79-
CMD ["rails", "s"]
75+
CMD ["bundle", "exec", "rails", "s"]

bin/docker-entrypoint-web

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,12 @@ if compgen -G "${manifest_files}" > /dev/null 2>&1; then
2121
-delete
2222
fi
2323

24+
if bundle check
25+
then
26+
echo "Bundle installing..."
27+
bundle install --jobs="$(nproc)" > ${BUNDLE_PATH}/bundle_install
28+
tail -n 2 ${BUNDLE_PATH}/bundle_install
29+
else
30+
bundle install --jobs=$(nproc)
31+
fi
2432
exec "$@"

docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ x-app: &default-app
2121
tty: true
2222
volumes:
2323
- "${DOCKER_WEB_VOLUME:-./public:/app/public}"
24+
- "${DOCKER_BUNDLE_VOLUME:-./vendor/bundle:/app/vendor/bundle}"
2425

2526
x-assets: &default-assets
2627
build:
@@ -39,6 +40,8 @@ x-assets: &default-assets
3940
tty: true
4041
volumes:
4142
- ".:/app"
43+
- "${DOCKER_BUNDLE_VOLUME:-./vendor/bundle:/app/vendor/bundle}"
44+
4245

4346
services:
4447
postgres:
@@ -101,7 +104,7 @@ services:
101104

102105
cable:
103106
<<: *default-app
104-
command: "puma -p 28080 cable/config.ru"
107+
command: "bundle exec puma -p 28080 cable/config.ru"
105108
entrypoint: []
106109
deploy:
107110
resources:

0 commit comments

Comments
 (0)