diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..f55e7db
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,24 @@
+FROM perl:stable
+
+RUN cpanm Config::Std \
+ && cpanm Template \
+ && cpanm Template::Plugin::DBI \
+ && cpanm Template::Plugin::HTML::Strip \
+ && cpanm DBD::SQLite \
+ && cpanm Tie::DBI \
+ && cpanm Date::Calc \
+ && cpanm Text::CSV_XS \
+ && cpanm HTML::Entities \
+ && mkdir -p /usr/src/app
+
+WORKDIR /usr/src/app
+
+ADD site-generator /usr/src/app/site-generator
+ADD site.cfg /usr/src/app/site.cfg
+ADD templates /usr/src/app/templates
+ADD LICENSE /usr/src/app/LICENSE
+
+# Tell Perl where to find the local modules
+ENV PERL5LIB=/usr/local/lib/perl5/site_perl
+
+ENTRYPOINT ["/usr/src/app/site-generator"]
diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md
index 2a4fa4a..ef17fd4 100644
--- a/GETTING_STARTED.md
+++ b/GETTING_STARTED.md
@@ -11,7 +11,9 @@ password are required), run:
On success, an "hpr_generator" directory will be created in the folder from
which the clone command was executed containing a local copy of the git repository.
-# Install required Perl modules
+# Building on local system
+
+## Install required Perl modules
Installing the Perl modules is the most finicky part of the installation process.
The needed Perl modules can be found using the operating system's package
@@ -34,7 +36,7 @@ apt install libconfig-std-perl \
```
-## Using CPAN to install the modules
+### Using CPAN to install the modules
A cross platform method to install the needed modules is the Perl CPAN application.
Make sure that the [gcc](https://www.gnu.org/software/gcc/),
@@ -55,7 +57,7 @@ cpan Tie::DBI
cpan Text:CSV_XS
```
-## Testing for Perl module dependencies
+### Testing for Perl module dependencies
A bash script is included in the utils directory that will list the Perl modules used by the site-generator and report whether the modules are installed on the current OS.
@@ -65,6 +67,39 @@ It can be run from any directory. To run from the utils directory:
./check-dependencies.sh
```
+# Building with Docker
+
+The docker file will copy the local version of the site-generator program, the templates directory, the LICENSE file,
+and the site.cfg file into the Docker image. For the docker image to run correctly it needs access to your local
+hpr.db file and the output directory (defaults to "public_html"). The default site.cfg assumes the hpr.db is located
+in the directory from which the site-generator is run. There are two ways to make the db available to the container:
+
+* Put the hpr.db file in the public_html folder and modify the driver option under the [DBI] section of the site.cfg to:
+ ```driver: dbi:SQLite:public_html/hpr.db```
+* mount the hpr.db file into the container when starting up the container with the -v option:
+ ```-v /hpr.db:/usr/src/app/hpr.db```
+
+Build the image by running the following command from the hpr_generator directory:
+```docker build -t hpr/site-generator .```
+
+The first build will take a while. It must pull down the base container, perl-latest, and then pull down and build the
+various Perl modules from CPAN. After the initial build, if you have modified your site.cfg file, templates dir, or the
+site-generator program itself, builds will be very quick.
+
+If the build fails, it is often from a CPAN module failing to download and install. Try running the Docker build command again.
+
+## Running the container
+
+When runing the Docker image, your local output directory (typically public_html) must be mounted into the container using
+the -v option. If you are using the default path for the hpr.db, then the local hpr.db file must also be mounted into the image.
+The following is an example of running the site-generator with default locations from the hpr_generator directory:
+```
+docker run \
+-v "$(pwd)/public_html":/usr/src/app/public_html \
+-v "$(pwd)/hpr.db":/usr/src/app/hpr.db \
+hpr/site-generator --help
+```
+
# Create the HPR database
The hpr_generator relies on information from a database to generate many of the
diff --git a/README.md b/README.md
index 623d13c..244bce7 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,9 @@
Static web page generator for the Hacker Public Radio website.
## Installation
+
+### On local system
+
* Clone or download this repository
* With SQLite
* Create the sqlite3 database from the hpr.sql MySQL dump file available on
@@ -31,6 +34,10 @@ Static web page generator for the Hacker Public Radio website.
* Text::CSV_XS
* HTML::Entities
+### Using Docker
+
+* run: `docker build -t hpr/site-generator .`
+
* See the [Getting Started](GETTING_STARTED.md) tutorial for more details on
installing the HPR generator.
diff --git a/site-generator b/site-generator
index d1dcf12..3261ad8 100755
--- a/site-generator
+++ b/site-generator
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
# {{{ POD documentation