OpenACS using S6

Table of Contents
Login

About

This is OpenACS on Ubuntu base docker image (version 22.04) using s6-overlay. To install OpenACS I used code from Gustaf Neumann script install-oacs.sh. The base image is oupfiz5/openacs-s6.

OpenACS-S6 is self-hosting at https://chiselapp.com/user/oupfiz5/repository/openacs-s6.

If you are reading this on GitHub, then you are looking at a Git mirror of the self-hosting OpenACS-S6 repository. The purpose of that mirror is to test and exercise Fossil's ability to export a Git mirror and using GitHub CI/CD (GitHub Actions). Nobody much uses the GitHub mirror, except to verify that the mirror logic works. If you want to know more about OpenACS-S6, visit the official self-hosting site linked above.

Prerequisite

Tools

  1. *nix operation system
  2. Install Docker
  3. Install git (optional)
  4. Install fossil (optional)

Third party tools

They are using for testing and scanning:

  1. Bats
  2. Shellcheck
  3. Hadolynt
  4. Dockle
  5. Snyk - not necessarily
  6. Trivy - not necessarily

Installation

Build from chiselapp (fossil)

fossil clone https://chiselapp.com/user/oupfiz5/repository/openacs-s6 openacs-s6.fossil
mkdir openacs-s6
cd openacs-s6
fossil open ../openacs-s6.fossil
docker build -t oupfiz5/openacs-s6 -f ./Dockerfile .

Download from DockerHub

You can download docker images from dockerhub:

docker pull oupfiz5/openacs-s6:v3-oacs-5-10

Build from GitHub

git clone https://github.com/oupfiz5/openacs-s6.git
cd openacs-s6
docker build -t oupfiz5/openacs-s6 -f ./Dockerfile .

Configuration

Build arguments

Arguments Default Description
BUILD_DATE none Set build date for label
OACS_TAG oacs-5-10 Set OpenACS version
NS_IMAGE_TAG 4.99.24 Set NaviServer version
NS_IMAGE_REPOSITORY oupfiz5 Set NaviServer repository
NS_IMAGE_NAME naviserver-s6 Set NaviServer image name
IMAGE_NAME openacs-s6 Set OpenaACS image name
IMAGE_REPOSITORY oupfiz5 Set OpenACS repository
IMAGE_TAG v3-oacs-5-10 Set OpenACS image tag

Example of build

set -a; source ../VERSIONS ; set +a;

IMAGE="${IMAGE:-${IMAGE_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}}"

docker build --no-cache \
    --build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
    --build-arg OACS_TAG="oacs-5-10" \
    -t "${IMAGE}" \
    -f ./Dockerfile \
    .

Quickstart

Manage OpenACS using docker compose

Prerequisite

Clone repository from:

Start/stop interactive

start:

docker compose up

The site will be accessible by url http://localhost:8080.

stop:

<Ctrl>+C

Start/stop/remove as daemon

start :

docker compose up -d

The site will be accessible by url http://localhost:8080.

stop:

docker compose down

remove:

docker compose rm

View logs

Logs follow:

docker compose logs -f

Logs tail:

docker compose logs --tail=10

View list containers

docker compose ps

Prune all

docker system prune --volumes --force

Configuration options

General options

Option Default Description
NS_CONF openacs-config.tcl Full path to configuration file
oacs_db_host* ${PGHOST} Set database host for OpenACS
oacs_db_name* ${PGDATABASE} Set database name for OpenACS
oacs_db_passwod* ${PGPASSWORD} Set db user password for OpenACS
oacs_db_port* ${PGPORT} Set database port for OpenACS
oacs_db_user* ${PGUSER} Set database user for OpenACS
oacs_httpport* 8000 Set listen port for OpenACS
OACS_IMAGE_NAME openacs-s6 Set OpenACS image name
OACS_IMAGE_TAG v3-oacs-5-10 Set OpenACS image tag
oacs_ipaddress* 0.0.0.0 Set listen address for OpenACS
OACS_LISTEN_PORT 8080 Set http listen port, example 8080
OACS_REPOSITORY oupfiz5 Set OpenACS repository name
PGDATABASE openacs Database name
PGHOST postgres Database host name
PGPASWORD testing Database user password
PGPORT 5432 Database port
PGUSER openacs Database user name
POSTGRES_DB ${PGDATABASE} Set postgres db name for docker image
POSTGRES_PASSWORD ${PGPASSWORD} Set postgres db password for docker image
POSTGRES_USER ${PGUSER} Set postgres db user for docker image
POSTGRES_REPOSITORY postgres Set default postgres repository
POSTGRES_TAG 14.1-alpine Set default postgres tag
TZ UTC Set timezone, example Europe/Moscow

All options have predifined values and store in .env file.

oacs_* variables

Setting these variables as environment variables with the "oacs_" prefix (suitable for e.g. docker setups for defaultConfig in NS_CONF (see naviserver commit). Code example from NaviServer configuration file is:

...
# All default variables in defaultConfig can be overloaded by
# 1) setting these variables in this file (highest precedence)
# 2) setting these variables as environment variables with
#    the "oacs_" prefix (suitable for e.g. docker setups)
# 3) set the variables from the default values.
#
set defaultConfig {
    hostname	localhost
    ipaddress	127.0.0.1
    httpport	8000
    httpsport	""

    server     "openacs"
    serverroot	/var/www/$server
    logroot	$serverroot/log/
    homedir	/usr/local/ns
    bindir	$homedir/bin
    db_name	$server
    db_user	$server
    db_host	localhost
    db_port	""
    db_password	"testing"
}
...

Environment variables from .env file are:

...
oacs_httpport='8000'
oacs_db_user="${PGUSER}"
oacs_db_passwod="${PGPASSWORD}"
oacs_db_name="${PGDATABASE}"
oacs_db_host="${PGHOST}"
oacs_db_port="${PGPORT}"
oacs_ipaddress='0.0.0.0'
...

OpenACS listen port

OACS_LISTEN_PORT set the http listen port for the openacs. In this case the OpenACS is accessible by URL http://localhost:8070.

OACS_LISTEN_PORT=8070 docker compose up

OpenACS docker image

Docker-compose uses the following variables for pulling OpenACS image from docker hub:

NaviServer configuration file

NS_CONF - configuration file. Default value is /usr/local/ns/conf/openacs-config.tcl

  1. Put the configuration file to rootfs/usr/local/ns/conf
  2. Run docker compose

    NS_CONF="/usr/local/ns/conf/my-config.tcl" docker-compose up
    

PostgreSQL docker image

Docker-compose uses the following variables for pulling postgres image from docker hub:

Database hostname

PGHOST set the database hostname for the openacs. By default it has name of docker-compose database service - postgres.

PGHOST=foo docker compose up

Database name

PGDATABASE set the database name for the openacs. By default it has name of docker-compose database service - openacs.

PGDATABASE=foo docker compose up

Database username

PGUSER set the database username for the openacs and postgres.

PGUSER=foouser docker compose up

Database password

PGPASSWORD set the database user password for the openacs and postgres.

PGPASSWORD=foopass docker compose up

Postgres tag

POSTGRES_TAG set the docker image tag for official postgres. Pay attention - some openacs version can use only correspond version of postgres.

POSTGRES_TAG="14.1-alpine" docker-compose up

Timezone

Set the timezone for the containers, defaults to UTC. To set the timezone set the desired timezone with the variable TZ. Useful for setup correct time in logging.

TZ="Europe/Moscow" docker compose up

CI/CD

For build and push docker images we use GitHub Actions workflow.

Maintenance

Shell access

For debugging and maintenance purposes you may want access the containers shell. If you are using Docker version 1.3.0 or higher you can access a running containers shell by starting bash using docker exec:

docker exec -it openacs-s6_openacs_1 /bin/bash

docker exec -it openacs-s6_postgres_1 /bin/bash