From 7cea36879c2b9ce98fea95d6319c68f84365996a Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Sun, 17 May 2026 10:09:33 -0400 Subject: [PATCH 1/6] Add a Dockerfile which builds a site-generator app This builds the container with the needed Perl modules, templates, and a default configuration file. --- Dockerfile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6921f14 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM perl:stable + +RUN cpan 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"] -- 2.47.3 From 5bdda3c1ef673d6b2fc44a40c837ba1a363f7aa4 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Sun, 17 May 2026 10:32:04 -0400 Subject: [PATCH 2/6] Set env to perl Instead of calling perl directly from /usr/bin, set environment so that the current default perl program is called. --- site-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.47.3 From 47b2c588b8a62d34ac0c13e5c66e65382d12853e Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Sun, 17 May 2026 11:39:40 -0400 Subject: [PATCH 3/6] Add instructions for building and running Docker images --- GETTING_STARTED.md | 39 ++++++++++++++++++++++++++++++++++++--- README.md | 7 +++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 2a4fa4a..0bd0789 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,37 @@ 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 run -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. + +## 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. -- 2.47.3 From 3cc4a6b5d3fcf9d67de5447b325aada5e881e1e9 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Sun, 17 May 2026 12:01:40 -0400 Subject: [PATCH 4/6] Fix cpanm call in run layer --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6921f14..f55e7db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM perl:stable -RUN cpan cpanm Config::Std \ +RUN cpanm Config::Std \ && cpanm Template \ && cpanm Template::Plugin::DBI \ && cpanm Template::Plugin::HTML::Strip \ -- 2.47.3 From fd577942e6710c87bb6183e1fb4181a5539d5543 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Sun, 17 May 2026 19:31:49 -0400 Subject: [PATCH 5/6] Update Docker build instructions --- GETTING_STARTED.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 0bd0789..8990c4d 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -86,6 +86,8 @@ The first build will take a while. It must pull down the base container, perl-la 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 -- 2.47.3 From e1be81a4adf6c642c6dbd89db734f231f6dea63f Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Tue, 19 May 2026 13:57:26 -0400 Subject: [PATCH 6/6] Fix Docker build instruction example --- GETTING_STARTED.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 8990c4d..ef17fd4 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -80,7 +80,7 @@ in the directory from which the site-generator is run. There are two ways to mak ```-v /hpr.db:/usr/src/app/hpr.db``` Build the image by running the following command from the hpr_generator directory: -```docker run -t hpr/site-generator .``` +```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 -- 2.47.3