envygeeks / jekyll-docker

⛴ Docker images, and CI builders for Jekyll.
ISC License
998 stars 281 forks source link

Bundles are not installed in `/vendor/bundle`, cannot launch server offline #348

Open T3sT3ro opened 2 years ago

T3sT3ro commented 2 years ago

When starting a jekyll/jekyll:4.0 (and 4.2.2) with volume ./vendor/bundle:/usr/local/bundle:Z, installed gems don't cache locally. They install into /usr/gem, so starting jekyll server without internet access is impossible.

I tried attaching to container and doing any combination of bundle cache, bundle package, bundle update, bundle install, bundle install --deployment, but nothing populates the vendor/bundle...

Here is my docker-compose.yml:

services:

  jekyll-server:
    image: jekyll/jekyll:4.2.2
    volumes:
      - .:/srv/jekyll:Z
      - ./vendor/bundle:/usr/local/bundle:Z
    ports:
      - '[::1]:4000:4000'
      - '[::1]:35729:35729'
    command: jekyll serve --livereload

  bundle-install: 
    image: jekyll/jekyll:4.2.2
    volumes:
      - .:/srv/jekyll:Z
      - ./vendor/bundle:/usr/local/bundle:Z # mount to update gems cache
    command: bundle update
T3sT3ro commented 2 years ago

I managed to make it (kind of?) retain it's gems, by using bundle config --local path vendor inside a container with mounted volume. This resulted in the addition of BUNDLE_PATH: "vendor" line inside the vendor/bundle/config.

Still, I think there should be some easier way to do that, and the image should be updated. My current Gemfile is

Gemfile ```rb source "https://rubygems.org" # Hello! This is where you manage which Jekyll version is used to run. # When you want to use a different version, change it below, save the # file and run `bundle install`. Run Jekyll with `bundle exec`, like so: # # bundle exec jekyll serve # # This will help ensure the proper Jekyll version is running. # Happy Jekylling! gem "jekyll", "~> 4.3.1" # This is the default theme for new Jekyll sites. You may change this to anything you like. gem "minima", "~> 2.5.1" # If you want to use GitHub Pages, remove the "gem "jekyll"" above and # uncomment the line below. To upgrade, run `bundle update github-pages`. # gem "github-pages", group: :jekyll_plugins # If you have any plugins, put them here! group :jekyll_plugins do # gem "jekyll-feed", "~> 0.17.1" end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem # and associated library. install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do gem "tzinfo", "~> 2.0.5" gem "tzinfo-data" end # Performance-booster for watching directories on Windows gem "wdm", "~> 0.1.1", :install_if => Gem.win_platform? ```