├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── assets └── demo.gif ├── onbuild └── Dockerfile └── update.sh /.gitignore: -------------------------------------------------------------------------------- 1 | _site/ 2 | .sass-cache/ 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM starefossen/ruby-node:2-6-alpine 2 | 3 | ENV GITHUB_GEM_VERSION 202 4 | ENV JSON_GEM_VERSION 1.8.6 5 | 6 | RUN apk --update add --virtual build_deps \ 7 | build-base ruby-dev libc-dev linux-headers \ 8 | && gem install --verbose --no-document \ 9 | json:${JSON_GEM_VERSION} \ 10 | github-pages:${GITHUB_GEM_VERSION} \ 11 | jekyll-github-metadata \ 12 | minitest \ 13 | && apk del build_deps \ 14 | && apk add git \ 15 | && mkdir -p /usr/src/app \ 16 | && rm -rf /usr/lib/ruby/gems/*/cache/*.gem 17 | 18 | WORKDIR /usr/src/app 19 | 20 | EXPOSE 4000 80 21 | CMD jekyll serve -d /_site --watch --force_polling -H 0.0.0.0 -P 4000 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Hans Kristian Flaatten 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Alpine Docker GitHub Pages [![Image Layers](https://images.microbadger.com/badges/image/starefossen/github-pages.svg)](https://microbadger.com/#/images/starefossen/github-pages) 2 | 3 | Alpine Docker image for running GitHub Pages / Jekyll projects. Only 70 MB. 4 | 5 | ![Demo using GitHub Page on Docker](https://raw.githubusercontent.com/Starefossen/docker-github-pages/master/assets/demo.gif) 6 | 7 | ## Supported tags and respective `Dockerfile` links 8 | 9 | * [`latest` (Dockerfile)](https://github.com/Starefossen/docker-github-pages/blob/master/Dockerfile) 10 | * [`onbuild` (Dockerfile)](https://github.com/Starefossen/docker-github-pages/blob/master/onbuild/Dockerfile) 11 | 12 | ## What is GitHub Pages 13 | 14 | GitHub Pages are public webpages hosted and published directly through your 15 | GitHub repository. 16 | 17 | ## How to use this image 18 | 19 | This image makes it easy to run your GitHub Pages page locally while developing – 20 | refreshing changes automatically as you make them. All you need to do is to mount 21 | your page in a volume under `/usr/src/app` like this: 22 | 23 | ``` 24 | $ docker run -it --rm -v "$PWD":/usr/src/app -p "4000:4000" starefossen/github-pages 25 | ``` 26 | 27 | Your Jekyll page will be available on `http://localhost:4000`. 28 | 29 | Remember to add all the gems to your `_config.yml` file in order to get all the 30 | different things to work correctly: 31 | 32 | ``` 33 | repository: your/repo 34 | 35 | gems: 36 | - jekyll-github-metadata 37 | - jekyll-mentions 38 | - jekyll-redirect-from 39 | - jekyll-sitemap 40 | - jemoji 41 | ``` 42 | 43 | Also, in order for the `{{ site.github }}` metadata variables to be populated 44 | you need to set the `JEKYLL_GITHUB_TOKEN` environment variable with your GitHub 45 | token. 46 | 47 | ``` 48 | $ docker run \ 49 | -t --rm \ 50 | -v "$PWD":/usr/src/app \ 51 | -e JEKYLL_GITHUB_TOKEN=my-github-token \ 52 | -p "4000:4000" starefossen/github-pages 53 | ``` 54 | 55 | ## Docker compose 56 | 57 | If you want to use Docker Compose instead, you can move a lot of the options into a `docker-compose.yml` at the root of your project: 58 | 59 | ``` 60 | version: '3' 61 | services: 62 | jekyll: 63 | image: starefossen/github-pages 64 | environment: 65 | - "JEKYLL_GITHUB_TOKEN:${JEKYLL_GITHUB_TOKEN}" 66 | ports: 67 | - "4000:4000" 68 | volumes: 69 | - ./:/usr/src/app 70 | tty: true 71 | ``` 72 | 73 | Then start the container with `docker-compose up`. 74 | 75 | ## Slow filesystem issues in Docker for Mac 76 | 77 | When running this image in [Docker for Mac](https://docs.docker.com/docker-for-mac/) you might experience slow page generation times. This is due to some limitations in the Docker for Mac filesystem integration. Changing the volume configuration to `-v "$PWD":/usr/src/app:delegated` will massively improve the page generation time, at the cost of delaying the generated files showing up in your host system slightly. In case you don't even need the generated pages on your host system, you can also exclude the `_site/` folder completely from being mounted by adding a container-only volume: `-v site:/usr/src/app/_site`. 78 | 79 | ## Image Variants 80 | 81 | The `starefossen/github-pages` images come in two flavors, each designed for a 82 | specific use case. 83 | 84 | `starefossen/github-pages:` 85 | 86 | This is the defacto image. If you are unsure about what your needs are, you 87 | probably want to use this one. It is designed to be used both as a throw away 88 | container (mount your source code and start the container to start your app), as 89 | well as the base to build other images off of. 90 | 91 | `starefossen/github-pages:onbuild` 92 | 93 | This image makes building derivative images easier. For most use cases, creating 94 | a `Dockerfile` in the base of your project directory with the line `FROM 95 | starefossen/github-pages:onbuild` will be enough to create a stand-alone image 96 | for your project. 97 | 98 | ## License 99 | 100 | This Docker image is licensed under the [MIT License](https://github.com/Starefossen/docker-github-pages/blob/master/LICENSE). 101 | 102 | Software contained in this image is licensed under the following: 103 | 104 | * github-pages gem: [MIT License](https://github.com/github/pages-gem/blob/master/LICENSE) 105 | * github-metadata gem: [MIT License](https://github.com/jekyll/github-metadata/blob/master/LICENSE) 106 | * jekyll: [MIT License](https://github.com/jekyll/jekyll/blob/master/LICENSE) 107 | * ruby: [2-clause BSDL](https://github.com/ruby/ruby/blob/trunk/COPYING) 108 | * iojs: [MIT License](https://github.com/iojs/io.js/blob/master/LICENSE) 109 | 110 | ## Supported Docker versions 111 | 112 | This image is officially supported on Docker version v17. 113 | 114 | Support for older versions (down to v1.0) is provided on a best-effort basis. 115 | 116 | ## User Feedback 117 | 118 | ### Documentation 119 | 120 | * [Docker](http://docs.docker.com) 121 | * [Jekyll](https://jekyllrb.com) 122 | * [GitHub Pages](https://pages.github.com) 123 | 124 | ### Issues 125 | 126 | If you have any problems with or questions about this image, please contact us 127 | through a [GitHub issue](https://github.com/Starefossen/docker-github-pages/issues). 128 | 129 | ### Contributing 130 | 131 | You are invited to contribute new features, fixes, or updates, large or small; 132 | we are always thrilled to receive pull requests, and do our best to process them 133 | as fast as we can. 134 | 135 | Before you start to code, we recommend discussing your plans through a [GitHub 136 | issue](https://github.com/Starefossen/docker-github-pages/issues), especially 137 | for more ambitious contributions. This gives other contributors a chance to 138 | point you in the right direction, give you feedback on your design, and help 139 | you find out if someone else is working on the same thing. 140 | -------------------------------------------------------------------------------- /assets/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Starefossen/docker-github-pages/a0fc71b7185fd4217e6b97f2962c729e45a437e2/assets/demo.gif -------------------------------------------------------------------------------- /onbuild/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM starefossen/github-pages:latest 2 | 3 | ONBUILD COPY . /usr/src/app 4 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | OLD_VERSION=$1 4 | NEW_VERSION=$2 5 | 6 | if [[ -z ${OLD_VERSION} || -z ${NEW_VERSION} ]]; then 7 | echo "Usage: update.sh [OLD_VERSION] [NEW_VERSION]" 8 | exit 1 9 | fi 10 | 11 | if [ -n "`git diff --staged`" ]; then 12 | echo "Error: Commit or unstage staged files" 13 | exit 1 14 | fi 15 | 16 | declare -a files=("README.md" "Dockerfile" "onbuild/Dockerfile") 17 | 18 | for file in "${files[@]}"; do 19 | sed -i '' "s/${OLD_VERSION}/${NEW_VERSION}/g" ${file} 20 | git add ${file} 21 | done 22 | 23 | if [ -z "`git diff --staged`" ]; then 24 | echo "Sorry, version ${OLD_VERSION} was not found." 25 | exit 1 26 | fi 27 | 28 | git commit -m "Tag release v${NEW_VERSION}" 29 | git tag -a "${NEW_VERSION}" -m "v${NEW_VERSION}" -s 30 | --------------------------------------------------------------------------------