Skip to content

Commit 22b2bd4

Browse files
Merge pull request #3993 from OpenLiberty/guides-docker-draft
Re-commit: Updating dockerfile for blogs and adding one for guides
2 parents 6039df9 + 92ec784 commit 22b2bd4

File tree

3 files changed

+94
-5
lines changed

3 files changed

+94
-5
lines changed

Dockerfile-blogs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Created by [email protected], Twitter/GitHub/Docker username: @lauracowen
22
# 2017-11-02
33
# Updated Oct. 2018 by Kin Ueng
4+
# Updated May 2024 by Mark Swatosh
45
# Installing and running Jekyll based on: based on https://blog.codeship.com/a-beginners-guide-to-the-dockerfile/
56
# NodeJS and NPM sections based on: https://gist.github.com/remarkablemark/aacf14c29b3f01d6900d13137b21db3a
67

@@ -15,10 +16,10 @@
1516
# docker build --tag lauracowen/jekyll .
1617
#
1718
# To run a container:
18-
# docker run --name jekyll -it -d -p 4000:4000 -v <root directory of Jekyll site on host machine>:/home/jekyll lauracowen/jekyll
19+
# docker run --name jekyll -it -d -p 4000:4000 -v <root directory of openliberty.io git repository on host machine>:/home/jekyll lauracowen/jekyll
1920

2021
# Use the official Ruby image as a parent image
21-
FROM ruby:latest
22+
FROM ruby:2.7.6
2223

2324
# INSTALL NODEJS AND NPM (it's a dependency of something in the Jekyll setup)
2425

@@ -69,7 +70,7 @@ WORKDIR /home/jekyll
6970

7071
# openliberty.io gem dependencies
7172
COPY ./scripts /home/jekyll/scripts
72-
RUN scripts/build_gem_dependencies.sh
73+
RUN scripts/build/gem_dependencies.sh
7374

7475
# openliberty.io custom gems
7576
COPY ./gems /home/jekyll/gems
@@ -84,4 +85,3 @@ ENTRYPOINT ["bash", "./scripts/jekyll_serve_dev.sh"]
8485
# Make port 4000 available to the world outside this container
8586
EXPOSE 4000
8687

87-

Dockerfile-guides

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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

scripts/build/gem_dependencies.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
echo "Installing ruby packages..."
2+
gem install ffi -v 1.16.3
3+
gem install public_suffix -v 5.1.1
24
gem install jekyll -v 3.8.6
35
gem install jekyll-assets -v 2.4.0
46
gem install jekyll-multiple-languages-plugin
5-
gem install bundler jekyll-feed jekyll-asciidoc jekyll-include-cache coderay uglifier octopress-minify-html octokit
7+
gem install bundler -v 2.4.22
8+
gem install faraday -v 2.8.1
9+
gem install faraday-net_http -v 3.0.2
10+
gem install jekyll-feed jekyll-asciidoc jekyll-include-cache coderay octokit
611
gem uninstall -i /usr/local/rvm/gems/ruby-2.4.1@global rubygems-bundler

0 commit comments

Comments
 (0)