diff --git a/Dockerfile-blogs b/Dockerfile-blogs index 1e6e18f9e..11b7e2bc1 100755 --- a/Dockerfile-blogs +++ b/Dockerfile-blogs @@ -1,6 +1,7 @@ # Created by laura_cowen@uk.ibm.com, Twitter/GitHub/Docker username: @lauracowen # 2017-11-02 # Updated Oct. 2018 by Kin Ueng +# Updated May 2024 by Mark Swatosh # Installing and running Jekyll based on: based on https://blog.codeship.com/a-beginners-guide-to-the-dockerfile/ # NodeJS and NPM sections based on: https://gist.github.com/remarkablemark/aacf14c29b3f01d6900d13137b21db3a @@ -15,10 +16,10 @@ # docker build --tag lauracowen/jekyll . # # To run a container: -# docker run --name jekyll -it -d -p 4000:4000 -v :/home/jekyll lauracowen/jekyll +# docker run --name jekyll -it -d -p 4000:4000 -v :/home/jekyll lauracowen/jekyll # Use the official Ruby image as a parent image -FROM ruby:latest +FROM ruby:2.7.6 # INSTALL NODEJS AND NPM (it's a dependency of something in the Jekyll setup) @@ -69,7 +70,7 @@ WORKDIR /home/jekyll # openliberty.io gem dependencies COPY ./scripts /home/jekyll/scripts -RUN scripts/build_gem_dependencies.sh +RUN scripts/build/gem_dependencies.sh # openliberty.io custom gems COPY ./gems /home/jekyll/gems @@ -84,4 +85,3 @@ ENTRYPOINT ["bash", "./scripts/jekyll_serve_dev.sh"] # Make port 4000 available to the world outside this container EXPOSE 4000 - diff --git a/Dockerfile-guides b/Dockerfile-guides new file mode 100644 index 000000000..2c7897fef --- /dev/null +++ b/Dockerfile-guides @@ -0,0 +1,84 @@ +# Installing and running Jekyll based on: based on https://blog.codeship.com/a-beginners-guide-to-the-dockerfile/ +# NodeJS and NPM sections based on: https://gist.github.com/remarkablemark/aacf14c29b3f01d6900d13137b21db3a + +# To build this image, from the directory that contains this Dockerfile: +# docker build -f Dockerfile-guides --tag olio/guides . +# +# To run a container: +# docker run --name guides -it -d -p 4000:4000 -v :/home/jekyll/src/main/content/guides/guide-new olio/guides +# + +# The guide will be available at http://localhost:4000/guides/{project-id}.html +# project-id is specified in the guide's README.adoc +# +FROM ruby:2.7.6 + +# INSTALL NODEJS AND NPM (it's a dependency of something in the Jekyll setup) + +# replace shell with bash so we can source files +RUN rm /bin/sh && ln -s /bin/bash /bin/sh + +# update the repository sources list +# and install dependencies +RUN apt-get update \ + && apt-get install -y curl \ + && apt-get -y autoclean + +# nvm environment variables +ENV NVM_DIR /usr/local/nvm +ENV NODE_VERSION 9.0.0 + +# install nvm +# https://github.com/creationix/nvm#install-script +RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash + +# install node and npm +RUN source $NVM_DIR/nvm.sh \ + && nvm install $NODE_VERSION \ + && nvm alias default $NODE_VERSION \ + && nvm use default + +# add node and npm to path so the commands are available +ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules +ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH + +# confirm installation +RUN node -v +RUN npm -v + +# INSTALLING AND RUNNING JEKYLL + +# create a user and group for Jekyll, set appropriate permissions, install the Jekyll gem +RUN mkdir -p /home/jekyll \ + && groupadd -rg 1000 jekyll \ + && useradd -rg jekyll -u 1000 -d /home/jekyll jekyll \ + && chown jekyll:jekyll /home/jekyll + +# Set the working directory +WORKDIR /home/jekyll + +#Copy files +COPY ./src /home/jekyll/src +COPY ./scripts /home/jekyll/scripts +COPY ./gems /home/jekyll/gems + +# openliberty.io gem dependencies +RUN scripts/build/gem_dependencies.sh + +# openliberty.io custom gems +RUN pushd gems/ol-target-blank \ + && gem build ol-target-blank.gemspec \ + && gem install ol-target-blank-0.0.1.gem \ + && popd + +# Create a mount point where Docker can access a guide on the local system +RUN mkdir -p /home/jekyll/src/main/content/guides/guide-new +RUN git clone https://github.com/OpenLiberty/guides-common.git /home/jekyll/src/main/content/guides/guides-common +VOLUME /home/jekyll/src/main/content/guides/guide-new + +# Serve the site +# scripts/jekyll_serve_dev.sh with --force-polling because file change notifications don't work over docker volumes +ENTRYPOINT jekyll s --host 0.0.0.0 --force-polling --future --source src/main/content --config src/main/content/_config.yml,src/main/content/_dev_config.yml --drafts + +# Make port 4000 available to the world outside this container +EXPOSE 4000 \ No newline at end of file diff --git a/scripts/build/gem_dependencies.sh b/scripts/build/gem_dependencies.sh index c573368c9..f86639a58 100755 --- a/scripts/build/gem_dependencies.sh +++ b/scripts/build/gem_dependencies.sh @@ -1,6 +1,11 @@ echo "Installing ruby packages..." +gem install ffi -v 1.16.3 +gem install public_suffix -v 5.1.1 gem install jekyll -v 3.8.6 gem install jekyll-assets -v 2.4.0 gem install jekyll-multiple-languages-plugin -gem install bundler jekyll-feed jekyll-asciidoc jekyll-include-cache coderay uglifier octopress-minify-html octokit +gem install bundler -v 2.4.22 +gem install faraday -v 2.8.1 +gem install faraday-net_http -v 3.0.2 +gem install jekyll-feed jekyll-asciidoc jekyll-include-cache coderay octokit gem uninstall -i /usr/local/rvm/gems/ruby-2.4.1@global rubygems-bundler