version: '3'
services:

  # serve

  serve:
    container_name: isabelline-serve
    image: jekyll/jekyll:3.8
    # command: bash -c "bundle update && bundle exec jekyll serve --host 0.0.0.0 --future --draft --force_polling --livereload"
    command: jekyll serve --host 0.0.0.0 --future --draft --force_polling --livereload
    environment:
      JEKYLL_ENV: local
    ports:
      - 4000:4000
      - 35729:35729
    volumes:
      - .:/srv/jekyll
      - .bundle:/usr/local/bundle

  # build and push to rubygems.org

  gem-push:
    container_name: jekyll-gem-push
    image: jekyll/jekyll:3.8
    command: >
      bash -c "gem build -v jekyll-theme-isabelline.gemspec \
        && GEM_VER=`ruby -e '\
          require \"rubygems\"; \
          spec = Gem::Specification::load(\"jekyll-theme-isabelline.gemspec\"); \
          puts \"#{spec.version}\"'` \
        && gem push jekyll-theme-isabelline-$${GEM_VER}.gem
      "
    volumes:
      - .:/srv/jekyll
      - .bundle:/usr/local/bundle
      - ./.gem:/root/.gem

  # helpers

  jekyll:
    container_name: jekyll
    image: jekyll/jekyll:3.8
    entrypoint: jekyll
    environment:      
      JEKYLL_ENV: local
    volumes:
      - .bundle:/usr/local/bundle
      - .:/srv/jekyll

  gem:
    container_name: jekyll-gem
    image: jekyll/jekyll:3.8
    entrypoint: gem
    volumes:
      - .bundle:/usr/local/bundle
      - .:/srv/jekyll

  bundle:
    container_name: bundle
    image: jekyll/jekyll:3.8
    entrypoint: bundle
    volumes:
      - .bundle:/usr/local/bundle
      - .:/srv/jekyll
      - ./.gem:/root/.gem
