Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0041e7c
Update ubuntu and ruby and thus jekyll version
white-gecko Jun 10, 2016
60e75c9
move files to top level
white-gecko Jun 10, 2016
496d3c5
Add reference to origin and to docker hub location
white-gecko Jun 10, 2016
6f82f35
Set index
white-gecko Jun 8, 2017
9dc5d63
Update nginx config for try order
white-gecko Jun 8, 2017
91c7d1b
Fix nginx config
white-gecko Jun 8, 2017
26ac14a
Fix try order for nginx
white-gecko Jun 8, 2017
4d1260f
Add support for arbitrary plugins using bundler
white-gecko Jun 14, 2017
67edca3
Configure usage of an error 404 page
white-gecko Jun 19, 2017
e548d91
Improve build process to handle volumes and branches
white-gecko Jun 21, 2017
07387ca
Fix changelog in README
white-gecko Jun 21, 2017
c4ede04
Add support for including an SSH key
white-gecko Jun 23, 2017
52f0693
Remove apt list cache after installation
white-gecko Jun 27, 2017
e29bda3
Update README with 0.3.1 changes
white-gecko Jun 27, 2017
090f82e
Remove deb pacakges which are not needed to save space
white-gecko Jul 11, 2017
36b8718
Merge pull request #5 from white-gecko/feature/removeNotNeededPackages
white-gecko Jul 11, 2017
ad653bd
Update base image
white-gecko Jul 11, 2017
7ee1c9e
Merge branch 'feature/UpdateBaseImage'
white-gecko Jul 11, 2017
4600939
Update README --> Correct name of docker image from docker.hub
GezimSejdiu Sep 20, 2017
2932434
Merge pull request #7 from GezimSejdiu/master
white-gecko Sep 20, 2017
d6c1476
Add troubleshooting section
white-gecko Mar 22, 2018
45b8907
Add some hack to match turtle
white-gecko Nov 13, 2018
7e986ec
Update to cosmic
white-gecko Nov 13, 2018
d5a1ad6
Set default datatype for ttl location to text/turtle
white-gecko Nov 18, 2018
528bff7
Add CORS header to ttl location
white-gecko Nov 18, 2018
dc5b902
Add origin as CORS header
white-gecko Nov 28, 2018
ce52dc7
Add Access-Control-Allow-Credentials
white-gecko Nov 28, 2018
9ccd282
Add n3 and old turtle mimetypes
white-gecko Dec 8, 2018
9721af7
Update README.md
white-gecko Jun 8, 2022
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
20 changes: 14 additions & 6 deletions dockerjekyllpages/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
FROM ubuntu:trusty
MAINTAINER dmcnamara
FROM ubuntu:cosmic
MAINTAINER Natanael Arndt <arndtn@gmail.com>

ENV LANG C.UTF-8
ENV SSH_AUTH_SOCK /var/run/ssh-agent.sock

# Install
## zlib1g-dev is needed for nokogiri dependency of jekyll-rdf
## ruby-dev and build-essential are needed to build jekyll
RUN apt-get update && apt-get install -y \
git \
ruby1.9.1-full \
ruby \
ruby-dev \
build-essential \
nginx \
uwsgi \
uwsgi-core \
supervisor \
nodejs
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

RUN gem install --no-rdoc --no-ri jekyll
RUN gem install --no-rdoc --no-ri jekyll bundler

# Configure nginx.
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
Expand All @@ -26,5 +32,7 @@ ADD ./supervisor-app.conf /etc/supervisor/conf.d/
ADD ./buildsite.sh /data/cgi/buildsite.sh
RUN chmod +x /data/cgi/buildsite.sh

VOLUME /data/jekyll/source

EXPOSE 80
CMD ["supervisord", "-n"]
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
Maybe this is not state of the art anymore.
Better build your page with some CI/CD system and then serve it as static site with: https://github.com/white-gecko/mini-server.compose


This is a fork from https://github.com/DonMcNamara/dockerfiles/tree/master/dockerjekyllpages which is built at https://hub.docker.com/r/dmcnamara/dockerjekyllpages/

This repo is built at https://hub.docker.com/r/whitegecko/dockerjekyllpages/

### Description
This is a docker image to build a Jekyll page from a Git repository.
This is essentially githubpages in a docker image.
This docker image uses nginx, Jekyll, uwsgi and supervisor.

### Configuration of docker image
The git repository URL is passed as an environment variable to the docker image.
The environment variable is named `REPO`, also a branch to build can be specified using the variable `BRANCH`.
Alternatively the container can be linked to a volume at `/data/jekyll/source` which contains the Jekyll page to build.

#### Use SSH Authentication
If you want to clone private git repositories your might want to forward your private SSH key resp. the *SSH Authentication Socket*.
Per default the `SSH_AUTH_SOCK` environment variable is set to `/var/run/ssh-agent.sock` in this image thus you only have to mount the hosts `SSH_AUTH_SOCK` to the container by adding the argument `-v "$SSH_AUTH_SOCK:/var/run/ssh-agent.sock"`.
If you don't have an `SSH_AUTH_SOCK` running on the docker host you can also mount the `id_rsa`-file e.g. with `-v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa:ro`.
In the case that you are mounting a private key rather then using the hosts SSH agent it is a good idea to generate a key without password.

Usually you also want to tell the known hosts to the container so it doesn't prompt for the decision.
You can do this by mounting the hosts `known_hosts`-file with `-v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts:ro`.

### Triggering builds
To initiate a rebuild, you can use your browser to load http://yourserver/cgi/buildsite.sh

For an automatic build, you can set up a git service hook that posts to that URL on a git push.
Your site will rebuild when you push changes to your repository.

### Execution
Per default the site will be hosted on port 80.
This is especially useful in combination with a proxy container e.g. the one from [jwilder](https://hub.docker.com/r/jwilder/nginx-proxy/).

If you want to serve you site locally you can map it e.g. to port 8080:
```
sudo docker run -p 8080:80 -e REPO=[YOUR REPO URL HERE] -e BRANCH=[YOUR BRANCH] whitegecko/dockerjekyllpages
```

### Troubleshooting

#### Authenticity can't be established

If you experience that `./buildsite.sh` never ends and if you run it manually you get the following output:

The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?

You are using a ssh remote URL.

There are two solutions:

1. Use a HTTPS URL for the remote instead
2. Include a `known_hosts`-file as explained above in the "Use SSH Authentication"-section

### Changelog

#### 0.3.2
* Remove debian packages which are not used
* Update base image to ubuntu:zesty, latest and saves space

#### 0.3.1
* Remove apt list cache after installation with apt-get (should save some space)

#### 0.3.0 Add Support for private SSH repositories
* Set SSH_AUTH_SOCK environment variable per default
* README: Explain how to forward the respective SSH resources to the container

#### 0.2.0 Some Improvements
* Update base image, ruby and thus jekyll
* Reorganize file structure
* NGINX: also serve pages without .html
* NGINX: deliver 404 status codes
* NGINX: serve custom 404 pages
* Build process: install dependencies from Gemfile
* Build process: specify branch to checkout
* Build process: build from volume
* Update README

#### 0.1.0 Initial release.
* It seems to work.
52 changes: 52 additions & 0 deletions buildsite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

SOURCE="/data/jekyll/source"
TARGET="/data/jekyll/_site"

# Output an HTML header so this works as a CGI script.
echo "Content-type: text/html"
echo ""

echo "<HTML><BODY><PRE>"

if [ -z "$(ls -A $SOURCE)" ]
then
# $SOURCE is empty
if [ -z "$REPO" ]
then
echo "The source directory is empty and no repository is specified. I don't know what to build. :-("
exit 1
else
# pull down the repo
if [ -z "$BRANCH" ]
then
git clone $REPO $SOURCE
else
git clone --branch "$BRANCH" $REPO $SOURCE
fi
fi
else
cd $SOURCE
git pull || true
fi

if [ -s $SOURCE/Gemfile ]
then
cd $SOURCE

echo "Install dependencies from Gemfile"
# update gems
bundle install

# generate the site with jekyll
bundle exec jekyll build -s $SOURCE -d $TARGET
else
echo "No Gemfile found use standard jekyll installation"
# generate the site with jekyll
jekyll build -s $SOURCE -d $TARGET
fi

echo
date

echo "</PRE></BODY></HTML>"
24 changes: 0 additions & 24 deletions dockerjekyllpages/README.md

This file was deleted.

21 changes: 0 additions & 21 deletions dockerjekyllpages/buildsite.sh

This file was deleted.

11 changes: 0 additions & 11 deletions dockerjekyllpages/nginx.conf

This file was deleted.

33 changes: 33 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
server {

root /data/jekyll/_site;
index index.html;

location / {
if ($http_accept ~ "text\/turtle") {
rewrite ^(.*)$ /ttl$1 last;
}
if ($http_accept ~ "application\/x-turtle") {
rewrite ^(.*)$ /ttl$1 last;
}
if ($http_accept ~ "text\/n3") {
rewrite ^(.*)$ /ttl$1 last;
}
try_files $uri $uri.html $uri/ =404;
error_page 404 /404.html;
}

location /ttl {
default_type text/turtle;
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Credentials true;
index index.ttl;
try_files $uri $uri.ttl $uri/ =404;
}

location /cgi {
include uwsgi_params;
uwsgi_modifier1 9;
uwsgi_pass 127.0.0.1:3031;
}
}
File renamed without changes.
File renamed without changes.