Skip to content

utils: Add script to run Jekyll locally on a container #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ _site/
src/.jekyll-cache/
vendor/

# Container data
.vendor/

# temporary files
*~
*.swp
Expand Down
16 changes: 16 additions & 0 deletions utils/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ruby:alpine

RUN apk add --no-cache make gcc g++ libc-dev openssl-dev

VOLUME ["/srv/jekyll"]

EXPOSE 4000

ENV GEM_HOME="/usr/local/bundle"
ENV BUNDLE_PATH=/usr/local/bundle BUNDLE_SILENCE_ROOT_WARNING=1 BUNDLE_APP_CONFIG=/usr/local/bundle
ENV PATH=/usr/local/bundle/bin:/usr/local/bundle/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

RUN mkdir -p "/usr/local/bundle"

WORKDIR "/srv/jekyll"
ENTRYPOINT ["/bin/sh", "-c", "bundle install && bundle exec jekyll server --trace --host 0.0.0.0"]
34 changes: 34 additions & 0 deletions utils/local_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh


if [ "$1" == "-h" ]
then
echo -e "usage: local_serve.sh [-r] [-h]\n"
cat <<EOM
-h Display this help message and exit.
-r Force container rebuild.
EOM
exit 0
fi

SCRIPTDIR="$(realpath $(dirname $0))"
TOPDIR="$(dirname ${SCRIPTDIR})"

TAG="$(whoami)/ansible-freeipa_docs"

[ -d "${TOPDIR}/.vendor/bundle" ] || mkdir -p "${TOPDIR}/.vendor/bundle"

echo -n "Searching image... "
existing=$(podman images -f reference="localhost/${TAG}" --format "{{ .Repository }}")
echo "${existing:-NO}"

echo "Building image..."
[ "$1" == "-r" ] || [ -z "${existing}" ] && podman build -t "${TAG}" "${SCRIPTDIR}"

echo "Running container..."
podman run \
--volume "${TOPDIR}:/srv/jekyll:Z" \
--volume "${TOPDIR}/vendor/bundle:/usr/local/bundle:Z" \
-p 4000:4000 \
"${TAG}"