Skip to content
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

Nikola Dockerfile based on Debian latest. #3

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0e956d6
Created a Dockerfile based on the latest Ubuntu 14.04 image.
Dec 13, 2015
a897a7f
Minor changes to README.
Dec 13, 2015
e1d7cef
Minor edits.
Dec 13, 2015
6eaefdd
minor edits to README
Dec 13, 2015
85859d4
minor edits to README
Dec 13, 2015
3852797
minor edits to README
Dec 13, 2015
2075b89
After consulting the Nikola Handbook, I decided to try installing
Dec 13, 2015
74b10a2
Installed the nikola[extras] into a virtualenv. Changed the nikola file
Dec 13, 2015
26ace9a
Edited README to reflect that all features of Nikola working as
Dec 13, 2015
f5c9246
reformatted
Dec 13, 2015
55edce3
Uploaded the built image to Docker Hub. Edited to reflect that addition.
Dec 13, 2015
6b4438d
Improved readability with formatting.
Dec 14, 2015
e07e8c8
Added MAINTAINER to Dockerfile
Dec 15, 2015
7f0094d
Changed base image to debian as suggested in the dockerfile best
Dec 15, 2015
36b15a3
added script to build the base with dmmmdfll/nikola/debian tag
Dec 15, 2015
df36001
moved USER position
Dec 15, 2015
8a2e44e
Able to set the locale to US English and DK.
Dec 15, 2015
4c0ef77
removed jpeg package install
Dec 15, 2015
9cb86e3
added libjpeg62-turbo-dev to apt-get install list
Dec 15, 2015
f2cc764
added /nikola-virtualenv/bin to $PATH
Dec 15, 2015
de85757
removed python-virtualenv package, install virtualenv with pip3
Dec 15, 2015
cb5e1d3
$PATH properly updated to /nikola-virtualenv/bin so can call `nikola` in
Dec 15, 2015
8e7789b
changed to image name dmmmdfll/nikola/debian
Dec 15, 2015
6d09285
improved formatting
Dec 15, 2015
b09bdff
No more locale warnings when running nikola.
Dec 15, 2015
0dce16a
Haven't figured out yet how to put /nikola-virutalenv/bin on $PATH and
Dec 15, 2015
1c8d2db
Updated to reflect change to debian based image
Dec 15, 2015
b566b6b
trying to fix a link for Docker best practices
Dec 15, 2015
e0a6c47
trying to fix a link in rst
Dec 15, 2015
0ec08f0
fixing block quote
Dec 15, 2015
1a4ae9c
fixing block quote
Dec 15, 2015
124e28f
minor edits to README
Dec 15, 2015
fc95dba
minor edits to README
Dec 15, 2015
58636b1
minor edits to README
Dec 15, 2015
eda1066
minor edits to README
Dec 15, 2015
8c0839a
Merge branch 'edit-README'
Dec 15, 2015
76a486a
minor edits to README
Dec 15, 2015
ab383d5
minor edits to README
Dec 15, 2015
fe4b781
Merge branch 'master' of github.com:dmmmdfll/docker_nikola
Dec 15, 2015
ce1e63e
Corrected the docker image name.
Dec 15, 2015
f2e7e7c
added yuicompressor and java
Dec 20, 2015
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
81 changes: 40 additions & 41 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
# build command:
# docker build -t rbrewer123/nikola .
FROM debian:stable
MAINTAINER Don M <https://github.com/dmmmdfll/docker_nikola>

FROM nfnty/arch-mini

# add pkgbuilder repo
RUN echo '' >>/etc/pacman.conf
RUN echo '[pkgbuilder]' >>/etc/pacman.conf
RUN echo 'Server = https://pkgbuilder-repo.chriswarrick.com/' >>/etc/pacman.conf

# gnupg bugfix
RUN mkdir -p /root/.gnupg && \
touch /root/.gnupg/dirmngr_ldapservers.conf

RUN pacman-key -r 5EAAEA16
RUN pacman-key --lsign 5EAAEA16

RUN pacman -Syu --needed --noconfirm \
base-devel \
pkgbuilder \
python-webassets

RUN echo 'en_US.UTF-8 UTF-8' >>/etc/locale.gen
RUN echo 'en_DK.UTF-8 UTF-8' >>/etc/locale.gen
RUN locale-gen

RUN echo 'user ALL=(ALL) NOPASSWD: ALL' >/etc/sudoers.d/user
RUN useradd -m user

USER user
WORKDIR /home/user

RUN pkgbuilder --noconfirm \
python-pygal \
python-pyphen \
python-typogrify

RUN pkgbuilder --noconfirm \
python-nikola
ENV DEBIAN_FRONTEND noninteractive

USER root
WORKDIR /root

RUN userdel user
RUN rm -rf /home/user
RUN apt-get update -qq && apt-get install -y \
locales -qq

RUN echo 'en_US.UTF-8 UTF-8' >>/etc/locale.gen && \
echo 'en_DK.UTF-8 UTF-8' >>/etc/locale.gen && \
locale-gen && \
dpkg-reconfigure locales

RUN apt-get update && apt-get install -y \
-o APT::Install-Recommends=false -o APT::Install-Suggests=false \
build-essential \
python3-dev \
python3-pip \
python3-wheel \
libffi-dev \
libssl-dev \
libgtk2.0-0 \
libSM6 \
libxt6 \
libgpm2 \
libxml2-dev \
libxslt1-dev \
libjpeg62-turbo-dev \
libfreetype6 \
libfreetype6-dev \
default-jdk

RUN pip3 install \
virtualenv \
yuicompressor
RUN \
["/bin/bash", \
"-c", \
"virtualenv -p /usr/bin/python3 nikola-virtualenv && \
source /nikola-virtualenv/bin/activate && \
pip3 install --upgrade Nikola[extras]"]
RUN export PATH=$PATH:/nikola-virtualenv/bin

COPY runasuser.sh /root/
RUN chmod a+x /root/runasuser.sh
Expand Down
34 changes: 22 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,48 @@ Nikola Appliance
Purpose
###########

This ``Dockerfile`` creates a sandboxed, runnable `Nikola
<https://getnikola.com>`_ environment based on the latest official Arch
package produced by the Nikola team. This works in docker even if your
host system is not running Arch.
This ``Dockerfile`` creates a sandboxed, runnable `Nikola <https://getnikola.com>`_ environment built with the ``debian:stable`` image, Python developer packages, and the ``Nikola[extras]`` package installed.

The decision to use ``debian:stable`` was influenced by `this document <https://docs.docker.com/engine/articles/dockerfile_best-practices/>`_ ::

Whenever possible, use current Official Repositories as the basis for your image. We recommend the Debian image since it’s very tightly controlled and kept extremely minimal (currently under 100 mb), while still being a full distribution.

This image works in docker even if your host system is not running Debian.

Pull this image from `Docker Hub <https://hub.docker.com/r/dmmmdfll/nikola/>` with the command ``docker pull dmmmdfll/nikola``.

Requirements
################

This is tested with the following software:

* Nikola 7.7.2
* docker 1.8.0 (running on Ubuntu 14.04)
* Nikola 7.7.3
* Docker version 1.8.3, build f4bf5c7

Since it's main dependency is docker, it should run on any platform with
docker installed (e.g. Windows, OS X). It may or may not work with earlier
Since its main dependency is Docker, it should run on any platform with
Docker installed (e.g. Windows, OS X). It may or may not work with earlier
versions of docker. To install docker on your system, see the official
`docker installation instructions <https://docs.docker.com/installation>`_.


Installation
##############

To build the docker image::
To pull the docker image. (Depending on your connection speed this is likely much faster than building your own.) ::

$ docker build -t rbrewer123/nikola github.com/rbrewer123/docker_nikola
$ docker pull dmmmdfll/nikola

You can see your new image with this command::
Alternatively to pulling the docker image build the docker image with::

$ docker build -t dmmmdfll/nikola github.com/dmmmdfll/docker_nikola

You can see your new image that you either pulled or built with this command::

$ docker images

Grab the ``go`` script from github like this::

$ git clone https://github.com/rbrewer123/docker_nikola
$ git clone https://github.com/dmmmdfll/docker_nikola

Now update the ``docker_nikola/nikola`` script to use your correct
``username``, ``uid``, ``group``, and ``gid``. This avoids problems with
Expand All @@ -57,6 +65,8 @@ To run ``nikola`` from within the container, simply run the ``nikola`` script::
Limitations
#############

**I have not tried a deploy. I am leaving the following limitation from the forked repo at https://github.com/rbrewer123/docker_nikola because it seems likely that the same would be true for this image**

The only limitation I know of so far is using Nikola`s ``deploy`` command.
I'm using Nikola with Amazon S3, and the ``s3cmd`` I use to deploy my site
is not within the Nikola container. Since it's a single command to deploy
Expand Down
3 changes: 3 additions & 0 deletions build-base
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docker build \
-t dmmmdfll/nikola \
-f Dockerfile .;
15 changes: 13 additions & 2 deletions nikola
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#!/bin/bash

# run the container as a user to simplify writing files outside the container
docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) -p 8000:8000 rbrewer123/nikola -U rbrewer -u 1000 -G rbrewer -g 1000 nikola "$@"
# modify lines 11-14 with values to suit your environment regarding
# users and groups. This keeps the output files' permissions as expected.
# my username and group on my setup is 'ubuntu' and the ids are 1000, 1000
docker run --rm -it \
-v $(pwd):$(pwd) \
-w $(pwd) \
-p 8000:8000 \
dmmmdfll/nikola \
-U ubuntu \
-u 1000 \
-G ubuntu \
-g 1000 \
/nikola-virtualenv/bin/nikola "$@"