sylhare / Type-on-Strap

🎨 Simplistic, responsive jekyll based open source theme
https://sylhare.github.io/Type-on-Strap/
MIT License
814 stars 902 forks source link

git ls-files doesn't work #360

Closed nickchen120235 closed 2 years ago

nickchen120235 commented 2 years ago

Describe the bug When loading the gemspec file, the following error is shown.

[!] There was an error parsing `Gemfile`: 
[!] There was an error while loading `type-on-strap.gemspec`: No such file or directory - git. Bundler cannot continue.

 #  from /site/type-on-strap.gemspec:18
 #  -------------------------------------------
 #  
 >    spec.files                   = `git ls-files -z`.split("\x0").select do |f|
 #      f.match(%r!^(assets/(js|css|fonts|data)/|_(includes|layouts|sass)/|_data/(icons_builder.yml|language.yml)|(LICENSE|README.md))!i)
 #  -------------------------------------------
. Bundler cannot continue.

 #  from /site/Gemfile:2
 #  -------------------------------------------
 #  source "https://rubygems.org"
 >  gemspec
 #  -------------------------------------------

To Reproduce

  1. Use docker container bretfisher/jekyll-serve with command docker run --network bridge -p 4000:4000 -v $(pwd):/site bretfisher/jekyll-serve
  2. See error

Expected behavior The site should be successfully served.

Using type-on-strap 2.4.3 from source at `.`
Bundle complete! 1 Gemfile dependency, 32 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Configuration file: /site/_config.yml
            Source: /site
       Destination: /site/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
       Jekyll Feed: Generating feed for posts
                    done in 2.294 seconds.
 Auto-regeneration: enabled for '/site'
    Server address: http://0.0.0.0:4000/Type-on-Strap/
  Server running... press ctrl-c to stop.

Additional context After some googling, some suggest that git ls-files is not a recommended way to load files since git may not be present for some reason on target machine. I'm working on a PR that replaces the command with Dir["**/*"], which by my limited ruby knowledge, is equivalent to the current method.

sylhare commented 2 years ago

It seems more likely to be a bug from the docker image rather than from the theme. Can you share the dockerfile and the complete logs when you do docker run ?

nickchen120235 commented 2 years ago

Dockerfile (from its GitHub repo)

FROM ruby:2-slim-bullseye as jekyll

RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# used in the jekyll-server image, which is FROM this image
COPY docker-entrypoint.sh /usr/local/bin/

# install both bundler 1.x and 2.x incase you're running
# old gem files
# https://bundler.io/guides/bundler_2_upgrade.html#faq
RUN gem install bundler -v "~>1.0" && gem install bundler jekyll

EXPOSE 4000

WORKDIR /site

ENTRYPOINT [ "jekyll" ]

CMD [ "--help" ]

# build from the image we just built with different metadata
FROM ghcr.io/bretfisher/jekyll:latest as jekyll-serve

# on every container start, check if Gemfile exists and warn if it's missing
ENTRYPOINT [ "docker-entrypoint.sh" ]

CMD [ "bundle", "exec", "jekyll", "serve", "--force_polling", "-H", "0.0.0.0", "-P", "4000" ]

The complete log is the one attached in the first comment.

I also tried adding git while doing apt install but still didn't work.