commit 2bafacecb1b293fff06e3e99b84f51d67221adf6 Author: felix Date: Tue May 2 22:45:08 2017 +0200 initial commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c9cda3d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM python:2 +MAINTAINER Matthew Jackowski + +ENV REFRESHED_AT 2014-11-29 + +ENV SRV_DIR=//srv +ENV WORKING_DIR=//srv/pelican +ENV PORT=8000 + +ADD ./files $SRV_DIR +WORKDIR $WORKING_DIR +RUN mkdir output content cache +VOLUME ["$WORKING_DIR/"] + +RUN pip install -r requirements.txt +RUN chmod +x $SRV_DIR/develop_server.sh + +EXPOSE $PORT +CMD $SRV_DIR/develop_server.sh restart $PORT \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..7823cc0 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,10 @@ +Copyright (c) 2016, Matthew Jackowski +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fe042a6 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# Pelican Dockerfile + +A base docker setup that inherits Python 2 and loads a bunch of deps. It runs Pelican in autoload mode for dev. + +This is an easy to use image to setup a Pelican static website. +This image will run the Pelican devserver, which means it will watch for changes in the content and theme files. + +Also a volume has been added so you can simply map to an existing Pelican directory and the container will update the output. + +Some sane requirements have been pre-built into the image. + +The DockerHub repository can be found here: https://hub.docker.com/r/mjjacko/pelican/ + +![Using the image](http://i.giphy.com/l396GL1mien20Tap2.gif) + +## License + +[BSD 2-Clause license](http://opensource.org/licenses/bsd-license.php) diff --git a/files/develop_server.sh b/files/develop_server.sh new file mode 100644 index 0000000..29f561b --- /dev/null +++ b/files/develop_server.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +## +# This section should match your Makefile +## +PY=${PY:-python} +PELICAN=${PELICAN:-pelican} +PELICANOPTS= + +BASEDIR=$(pwd) +INPUTDIR=$BASEDIR/content +OUTPUTDIR=$BASEDIR/output +CONFFILE=$BASEDIR/pelicanconf.py + +### +# Don't change stuff below here unless you are sure +### + +SRV_PID=$BASEDIR/srv.pid +PELICAN_PID=$BASEDIR/pelican.pid + +function usage(){ + echo "usage: $0 (stop) (start) (restart) [port]" + echo "This starts Pelican in debug and reload mode and then launches" + echo "an HTTP server to help site development. It doesn't read" + echo "your Pelican settings, so if you edit any paths in your Makefile" + echo "you will need to edit your settings as well." + exit 3 +} + +function alive() { + kill -0 $1 >/dev/null 2>&1 +} + +function shut_down(){ + PID=$(cat $SRV_PID) + if [[ $? -eq 0 ]]; then + if alive $PID; then + echo "Stopping HTTP server" + kill $PID + else + echo "Stale PID, deleting" + fi + rm $SRV_PID + else + echo "HTTP server PIDFile not found" + fi + + PID=$(cat $PELICAN_PID) + if [[ $? -eq 0 ]]; then + if alive $PID; then + echo "Killing Pelican" + kill $PID + else + echo "Stale PID, deleting" + fi + rm $PELICAN_PID + else + echo "Pelican PIDFile not found" + fi +} + +function start_up(){ + local port=$1 + echo "Starting up Pelican and HTTP server" + shift + cd $BASEDIR; + $PELICAN --debug --autoreload -r $INPUTDIR -o $OUTPUTDIR -s $CONFFILE $PELICANOPTS & + pelican_pid=$! + echo $pelican_pid > $PELICAN_PID + if ! alive $pelican_pid ; then + echo "Pelican didn't start. Is the Pelican package installed?" + return 1 + fi + cd $OUTPUTDIR; + $PY -m pelican.server $port + srv_pid=$! + echo $srv_pid > $SRV_PID + if ! alive $srv_pid ; then + echo "The HTTP server didn't start. Is there another service using port" $port "?" + return 1 + fi + sleep 1 + echo 'Exiting Pelican and HTTP server processes.' +} + +### +# MAIN +### +[[ ($# -eq 0) || ($# -gt 2) ]] && usage +port='' +[[ $# -eq 2 ]] && port=$2 + +if [[ $1 == "stop" ]]; then + shut_down +elif [[ $1 == "restart" ]]; then + shut_down + start_up $port +elif [[ $1 == "start" ]]; then + if ! start_up $port; then + shut_down + fi +else + usage +fi diff --git a/files/pelican/pelicanconf.py b/files/pelican/pelicanconf.py new file mode 100644 index 0000000..a6c7bf6 --- /dev/null +++ b/files/pelican/pelicanconf.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- # +from __future__ import unicode_literals + +AUTHOR = u'Author' +SITENAME = u'Quickstart' +SITEURL = '' + +PATH = 'content' + +TIMEZONE = 'Europe/Paris' + +DEFAULT_LANG = u'en' + +# Feed generation is usually not desired when developing +FEED_ALL_ATOM = None +CATEGORY_FEED_ATOM = None +TRANSLATION_FEED_ATOM = None +AUTHOR_FEED_ATOM = None +AUTHOR_FEED_RSS = None + +# Blogroll +LINKS = (('Pelican', 'http://getpelican.com/'), + ('Python.org', 'http://python.org/'), + ('Jinja2', 'http://jinja.pocoo.org/'), + ('You can modify those links in your config file', '#'),) + +# Social widget +SOCIAL = (('You can add links in your config file', '#'), + ('Another social link', '#'),) + +DEFAULT_PAGINATION = 10 + +# Uncomment following line if you want document-relative URLs when developing +#RELATIVE_URLS = True diff --git a/files/pelican/publishconf.py b/files/pelican/publishconf.py new file mode 100644 index 0000000..00e50e4 --- /dev/null +++ b/files/pelican/publishconf.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- # +from __future__ import unicode_literals + +# This file is only used if you use `make publish` or +# explicitly specify it as your config file. + +import os +import sys +sys.path.append(os.curdir) +from pelicanconf import * + +SITEURL = 'http://example.com' +RELATIVE_URLS = False + +FEED_ALL_ATOM = 'feeds/all.atom.xml' +CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml' + +DELETE_OUTPUT_DIRECTORY = True + +# Following items are often useful when publishing + +#DISQUS_SITENAME = "" +#GOOGLE_ANALYTICS = "" diff --git a/files/pelican/requirements.txt b/files/pelican/requirements.txt new file mode 100644 index 0000000..d4cf1f4 --- /dev/null +++ b/files/pelican/requirements.txt @@ -0,0 +1,18 @@ +BeautifulSoup==3.2.1 +beautifulsoup4==4.3.2 +blinker==1.3 +docutils==0.12 +feedgenerator==1.7 +ghp-import==0.4.1 +Jinja2==2.7.3 +Markdown==2.6.2 +markdown-include==0.5.1 +markdown-attr-plus==0.3.0 +MarkupSafe==0.23 +pelican==3.5.0 +pelican-alias==1.1 +Pygments==2.0.2 +pytz==2015.2 +six==1.9.0 +Unidecode==0.04.17 +wsgiref==0.1.2