1+ # Installing and running Jekyll based on: based on https://blog.codeship.com/a-beginners-guide-to-the-dockerfile/
2+ # NodeJS and NPM sections based on: https://gist.github.com/remarkablemark/aacf14c29b3f01d6900d13137b21db3a
3+
4+ # To build this image, from the directory that contains this Dockerfile:
5+ # docker build -f Dockerfile-guides --tag olio/guides .
6+ #
7+ # To run a container:
8+ # docker run --name guides -it -d -p 4000:4000 -v <root directory of a guide git repository on host machine>:/home/jekyll/src/main/content/guides/guide-new olio/guides
9+ #
10+
11+ # The guide will be available at http://localhost:4000/guides/{project-id}.html
12+ # project-id is specified in the guide's README.adoc
13+ #
14+ FROM ruby:2.7.6
15+
16+ # INSTALL NODEJS AND NPM (it's a dependency of something in the Jekyll setup)
17+
18+ # replace shell with bash so we can source files
19+ RUN rm /bin/sh && ln -s /bin/bash /bin/sh
20+
21+ # update the repository sources list
22+ # and install dependencies
23+ RUN apt-get update \
24+ && apt-get install -y curl \
25+ && apt-get -y autoclean
26+
27+ # nvm environment variables
28+ ENV NVM_DIR /usr/local/nvm
29+ ENV NODE_VERSION 9.0.0
30+
31+ # install nvm
32+ # https://github.com/creationix/nvm#install-script
33+ RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash
34+
35+ # install node and npm
36+ RUN source $NVM_DIR/nvm.sh \
37+ && nvm install $NODE_VERSION \
38+ && nvm alias default $NODE_VERSION \
39+ && nvm use default
40+
41+ # add node and npm to path so the commands are available
42+ ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
43+ ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
44+
45+ # confirm installation
46+ RUN node -v
47+ RUN npm -v
48+
49+ # INSTALLING AND RUNNING JEKYLL
50+
51+ # create a user and group for Jekyll, set appropriate permissions, install the Jekyll gem
52+ RUN mkdir -p /home/jekyll \
53+ && groupadd -rg 1000 jekyll \
54+ && useradd -rg jekyll -u 1000 -d /home/jekyll jekyll \
55+ && chown jekyll:jekyll /home/jekyll
56+
57+ # Set the working directory
58+ WORKDIR /home/jekyll
59+
60+ #Copy files
61+ COPY ./src /home/jekyll/src
62+ COPY ./scripts /home/jekyll/scripts
63+ COPY ./gems /home/jekyll/gems
64+
65+ # openliberty.io gem dependencies
66+ RUN scripts/build/gem_dependencies.sh
67+
68+ # openliberty.io custom gems
69+ RUN pushd gems/ol-target-blank \
70+ && gem build ol-target-blank.gemspec \
71+ && gem install ol-target-blank-0.0.1.gem \
72+ && popd
73+
74+ # Create a mount point where Docker can access a guide on the local system
75+ RUN mkdir -p /home/jekyll/src/main/content/guides/guide-new
76+ RUN git clone https://github.com/OpenLiberty/guides-common.git /home/jekyll/src/main/content/guides/guides-common
77+ VOLUME /home/jekyll/src/main/content/guides/guide-new
78+
79+ # Serve the site
80+ # scripts/jekyll_serve_dev.sh with --force-polling because file change notifications don't work over docker volumes
81+ 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
82+
83+ # Make port 4000 available to the world outside this container
84+ EXPOSE 4000
0 commit comments