hydecorp / hydejack

A boutique Jekyll theme for hackers, nerds, and academics
https://hydejack.com
Other
1.42k stars 798 forks source link

Docker version of Hydejack #230

Closed ajaysjournal closed 3 years ago

ajaysjournal commented 4 years ago

The latest/pro version requires ruby 2.7 or above(correct me if I am wrong), for some reasons I dont want to upgrade ruby version, which might break other ruby projects. It would be great and easy, if we have docker version of Hyde jack. Just added a my version of Docker file below.

FROM ruby:2.7
RUN gem install bundler -v "~>1.0" && gem install bundler jekyll

RUN ruby -v

EXPOSE 4000

WORKDIR /home/user/
RUN mkdir website
WORKDIR /home/user/website
COPY hydejack-pro-9.0.3/starter-kit .

RUN ls
RUN git init
ENV JEKYLL_ENV=production
RUN bundle install
CMD [ "bundle", "exec", "jekyll", "serve", "--force_polling", "-H", "0.0.0.0", "-P", "4000", "--trace"]

How to run it ?

docker build --tag hydejack:9 .
docker run -p 4000:4000 hydejack:9

Issue

Fetching gem metadata from https://rubygems.org/.........
Fetching https://github.com/benbalter/jekyll-default-layout
Fetching https://github.com/hydecorp/jekyll-include-cache
Fetching https://github.com/hydecorp/jekyll-seo-tag
jekyll-theme-hydejack-9.0.3 requires ruby version ~> 2.6, which is incompatible with the current version, ruby 2.5.1p57
Could not find execjs-2.7.0 in any of the sources
Run `bundle install` to install missing gems.
qwtel commented 4 years ago

I've used the Jekyll Docker images before: https://github.com/envygeeks/jekyll-docker

Based on your error message Could not find execjs-2.7.0 in any of the sources it looks like kramdown-math-katex is the problem though. Have you tried removing it from the Gemfile? More on math support here: https://hydejack.com/docs/config/#enabling-math-blocks

ajaysjournal commented 4 years ago

@qwtel - Thanks, I will try your suggestion. Already started using docker-compose, and just don't want to fix on current system. Couple of times I faced env issue, I suggest this feature. Now the app is running on docker, also mounted the local volume to docker, so that it will dynamically builds the site when host files changed. Everything looks perfect in docker world :)

Docker file

execute touch Dockerfile and add below contents to it.

FROM ajaycs14/hydejack-base:latest
EXPOSE 4000
WORKDIR /code
COPY starter-kit .
RUN git init
ENV JEKYLL_ENV=production
RUN bundle install
CMD [ "bundle", "exec", "jekyll", "serve", "--force_polling", "-H", "0.0.0.0", "-P", "4000", "--watch"]

Docker Compose file

execute touch docker-compose.yml and add below contents to it.

version: '2.4'

services:
  blog:
    build: .
    volumes:
      - ./starter-kit:/code
    ports:
      - '24230:4000'

How to run

  1. Build the docker-compose using docker-compose build
  2. Run using docker-compose up
  3. Stop using docker-compose down

Troubleshooting

I added this on Gemfile, for some reasons I was not able to find JS runtime container env, some quick google search got fixed it.

gem "kramdown-math-katex" # add beloow 2 lines on gemfile
gem 'execjs'
gem 'therubyracer', :platforms => :ruby