Skip to content

Commit

Permalink
feat(jekyll): Add jekyll container with plantuml
Browse files Browse the repository at this point in the history
  • Loading branch information
evantill committed Mar 21, 2023
1 parent 4b41c7c commit 8ca94d9
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build-jekyll.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build jekyll container

on:
push:
tags:
- 'jekyll-v*'
pull_request:
paths:
- 'jekyll/**'
- '.github/workflows/**'
permissions:
contents: read
packages: write

jobs:
build-jekyll-container:
permissions:
contents: read
packages: write
uses: ./.github/workflows/build-container.yml
with:
component: "jekyll"
publish: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/jekyll-v') }}
secrets: inherit
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Release are provided using the [release-please-action](https://github.com/google
## List of containers

- [graalvm](graalvm/README.md)
- [jekyll](jekyll/README.md)

## Adding new container

Expand Down
15 changes: 15 additions & 0 deletions jekyll/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# https://stackoverflow.com/questions/28097064/dockerignore-ignore-everything-except-a-file-and-the-dockerfile
#

# Ignore everything
*

# Allow files and directories
!/rootfs

# Ignore unnecessary files inside allowed directories
# This should go after the allowed directories
**/*~
**/*.log
**/.DS_Store
**/Thumbs.db
2 changes: 2 additions & 0 deletions jekyll/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
site
.jekyll-cache
25 changes: 25 additions & 0 deletions jekyll/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG JEKYLL_VERSION=4.2.2

FROM jekyll/jekyll:${JEKYLL_VERSION}

# Copy files from repository.
# including container-test.sh
COPY ./rootfs /

RUN chmod a+x /usr/local/bin/plantuml && \
wget https://github.com/plantuml/plantuml/releases/download/snapshot/plantuml-SNAPSHOT.jar && \
mkdir -p /usr/local/share/plantuml && \
mv plantuml-SNAPSHOT.jar /usr/local/share/plantuml/plantuml.jar && \
gem install jekyll-plantuml

CMD ["jekyll", "--help"]

ENTRYPOINT ["/usr/jekyll/bin/entrypoint"]

WORKDIR /srv/jekyll

VOLUME /srv/jekyll

EXPOSE 35729

EXPOSE 4000
75 changes: 75 additions & 0 deletions jekyll/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Git variables

#GIT_REPOSITORY_NAME := $(shell basename `git rev-parse --show-toplevel`)
GIT_REPOSITORY_NAME := plantuml/jekyll

GIT_VERSION := $(shell git describe --always --tags --long --dirty | sed -e 's/\-0//' -e 's/\-g.......//')

# Docker variables

DOCKER_IMAGE_TAG ?= $(GIT_REPOSITORY_NAME):$(GIT_VERSION)
DOCKER_IMAGE_NAME := plantuml/jekyll

JEKYLL_SITE_NAME ?= myBlog
JEKYLL_SITE_ROOT_DIR := $(shell pwd)/site

# -----------------------------------------------------------------------------
# The first "make" target runs as default.
# -----------------------------------------------------------------------------

.PHONY: default
default: help

# -----------------------------------------------------------------------------
# Docker-based builds
# -----------------------------------------------------------------------------

.PHONY: build
build:
docker build \
--tag $(DOCKER_IMAGE_NAME) \
--tag $(DOCKER_IMAGE_NAME):$(GIT_VERSION) \
.

# -----------------------------------------------------------------------------
# Clean up targets
# -----------------------------------------------------------------------------

.PHONY: clean
clean:
-docker rmi --force \
$(DOCKER_IMAGE_NAME):$(GIT_VERSION) \
$(DOCKER_IMAGE_NAME)

# -----------------------------------------------------------------------------
# Test image
# -----------------------------------------------------------------------------

.PHONY: test
test:
docker run --rm --entrypoint /bin/bash $(DOCKER_IMAGE_NAME) container-test.sh

# -----------------------------------------------------------------------------
# Serve
# -----------------------------------------------------------------------------

.PHONY: serve
serve:
docker run --rm -it --volume="$(JEKYLL_SITE_ROOT_DIR):/srv/jekyll:Z" -p 4000:4000 $(DOCKER_IMAGE_NAME) jekyll-serve.sh $(JEKYLL_SITE_NAME)

# -----------------------------------------------------------------------------
# Enter
# -----------------------------------------------------------------------------

.PHONY: enter
enter:
docker run --rm -it --volume="$(JEKYLL_SITE_ROOT_DIR):/srv/jekyll:Z" $(DOCKER_IMAGE_NAME) bash

# -----------------------------------------------------------------------------
# Help
# -----------------------------------------------------------------------------

.PHONY: help
help:
@echo "List of make targets:"
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
18 changes: 18 additions & 0 deletions jekyll/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Jekyll container

Container base on [jekyll/jekyll](https://hub.docker.com/r/jekyll/jekyll/) container.

- JEKYLL_VERSION: 4.2.2

## Usage

### For testing

```shell
gh repo clone plantuml/docker
cd docker/jekyll
mkdir site

make build test serve
```
This will create a `myBlog` jekyll site under the `site` directory
6 changes: 6 additions & 0 deletions jekyll/rootfs/srv/jekyll/container-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -euo pipefail

jekyll --version

plantuml --version
25 changes: 25 additions & 0 deletions jekyll/rootfs/usr/local/bin/jekyll-serve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -xeuo pipefail

JEKYLL_SITE_NAME="${1?site name missing}"
JEKYLL_SITE_ROOT_DIR=/srv/jekyll
JEKYLL_SITE_DIR="$JEKYLL_SITE_ROOT_DIR/$JEKYLL_SITE_NAME"

cd $JEKYLL_SITE_ROOT_DIR

chown jekyll:jekyll -R $JEKYLL_SITE_ROOT_DIR

if [ ! -d $JEKYLL_SITE_DIR ]; then
echo "create site $JEKYLL_SITE_NAME..."
jekyll new $JEKYLL_SITE_NAME
cd $JEKYLL_SITE_NAME
echo "add missing bundles..."
bundle add \
public_suffix \
webrick
echo "site $JEKYLL_SITE_NAME is ready"
fi

echo "starting site $JEKYLL_SITE_NAME..."
cd $JEKYLL_SITE_DIR
jekyll serve
2 changes: 2 additions & 0 deletions jekyll/rootfs/usr/local/bin/plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
java -jar /usr/local/share/plantuml/plantuml.jar "$1" "$2"
1 change: 1 addition & 0 deletions jekyll/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
3 changes: 3 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"packages": {
"graalvm": {
"component": "graalvm"
},
"jekyll": {
"component": "jekyll"
}
}
}

0 comments on commit 8ca94d9

Please sign in to comment.