pkpofficial/ojs

Sponsored OSS

By Public Knowledge Project

Updated 18 days ago

Open Journal Systems

Image
Content management system
24

100K+

pkpofficial/ojs repository overview

OJS (Open Journal Systems) - PKP - Container/Docker

Open Journal Systems (OJS) is a journal management and publishing system that has been developed by the Public Knowledge Project through its federally funded efforts to expand and improve access to research.

The images in this repository were initially built on top of Alpine Linux but starting in version 3.5, we moved to Debian images. Additional changes could be included.

Images in this repository come in several variants (see Versions). This project is maintained by Marc Bria.

Images were built and tested in linux systems, but are supposed to work on windows. We don't offer yet ARM image, to they won't work in last Mac computers.

=========================================================================================================================
== WARNING
=========================================================================================================================
== 
== We are in a middle of a refactoring process so this description could be outdated and some information unprecise.
== Most updated documentation could be always found at [pkp/containers](https://github.com/pkp/containers) repository:
== 
== - https://github.com/pkp/containers/blob/main/README.md
== - https://github.com/pkp/containers/blob/main/docs/easyOJS.md
=========================================================================================================================

About tag naming

The rule of the thumb is "Docker images will have same name than OJS tags in the official repository" but with the app prefix. It means, if you like to pull an OJS version 3.3.0-17 (tagged as 3_3_0-17), you will only need to ask for it as pkpofficial/ojs-3_3_0-17.

We also keep alias for latest, lts and stable tags that will be updated as follows:

TagAlias for...Description
latest3_4_0-4Latest release
lts3_3_0-17Latest LTS version
stable-3_2_13_2_1-4Latest stable release for the refered branch

IMPORTANT: We only check the security of the image just released and the ones tagged as latest and LTS versions.

Image naming is still underdiscussion (what happens if we need to release a security patch in LAMP? Do we like to offer latest images? How to handle webserver/php/usage variants?...). Comment in the former document or if you want to talk about it.

How to use

TL;DR;

Be sure you properly installed docker and docker-compose.

git clone https://github.com/pkp/containers.git journalName && cd journalName
rm docs templates -Rf                               # Delete folders that are not useful in production
vim .env                         					# Set environment variables as you wish (ojs version, ports, url...)
source .env && wget "https://github.com/pkp/${PKP_TOOL}/raw/${PKP_VERSION}/config.TEMPLATE.inc.php" -O ./volumes/config/pkp.config.inc.php
sudo chown 33:33 ./volumes -R && sudo chown 999:999 ./volumes/db -R	# Ensure folders got the propper permissions
docker compose up -d
# Visit your new site and complete the installation as usual (Read about DB access credentials below, in step 5).

Extended version

Check "easyOJS" document for a detailed explanation.

Versions

Different OJS versions are combined with different versions of PHP (5 to 8...). In future we are planning to add variants with different web servers (Apache HTTP Server, nginx) and tools.

Currently, not all these combinations work! We are mostly focused in Apache2. PR are welcome

All version tags can be found at Docker Hub Tags tab.

(If no webserver is mentioned in the tag, then Apache is used).

Environment Variables

The image understand the following environment variables:

NAMEDefaultInfo
SERVERNAMElocalhostUsed to generate httpd.conf and certificate
PKP_TOOLojsPKP tool to be used (ojs, omp, ops). Only OJS images avaliable right now
PKP_VERSION3_3_0-14OJS version to be deployed
COMPOSER_PROJECT_NAMEmyjournalContainer's name
PKP_CLI_INSTALL0Used to install ojs automatically when start container
DB_HOSTdbDatabase host
DB_USERpkpDatabase
DB_PASSWORDojsPwdDatabase password
DB_NAMEojsDatabase name
HTTP_PORT8080Http port
HTTPS_PORT8443Https port

Note: OJS_CLI_INSTALL and certificate features are under construction.

Special Volumes

Docker content is efimerous by design, but in some situations you would like to keep some stuff persistent between docker restarts (ie: database content, upload files, plugin development...)

By default we include an structure of directories in the version folders (see ./volumes), but they are empty and disabled by default in your compose. To enable them, you only need to uncomment the volume lines in your docker-compose.yml and fill the folders properly.

When you run the docker-compose it will mount the volumes with persistent data and will let you share files from your host with the container.

HostContainerVolumeDescription
./volumes/publicapp/var/www/html/publicAll public files
./volumes/privateapp/var/www/filesAll private files (uploads)
./volumes/config/db.charset.confdb/etc/mysql/conf.d/charset.cnfmariaDB config file
./volumes/config/pkp.config.inc.phpapp/var/www/html/config.inc.phpOJS config file
./volumes/config/php.custom.iniapp/usr/local/etc/php/conf.d/custom.iniPHP custom.init
./volumes/config/apache.htaccessapp/var/www/html/.htaccessApache2 htaccess
./volumes/logs/appapp/var/log/apache2Apache2 Logs
./volumes/logs/dbdb/var/log/mysqlmariaDB Logs
./volumes/dbdb/var/lib/mysqlmariaDB database content
./volumes/migrationdb/docker-entrypoint-initdb.dDB init folder (with SQLs)
/etc/localtimeapp/etc/localtimeSync clock with the host one.
TBDapp/etc/ssl/apache2/server.pemSSL crt certificate
TBDapp/etc/ssl/apache2/server.keySSL key certificate

In this image we use "bind volumes" with relative paths because it will give you a clear view where your data is stored.

The down sides of those volumes is they can not be "named" and docker will store them with an absolute path (that it’s annoying to make stuff portable) but we prefer better control about where data is stored than leave it in docker hands.

And remember this is just an image, so feel free to modify to fit your needs.

You can add your own volumes. For instance, make sense for a plugin developer or a themer to create a volume with his/her work, to keep a persistent copy in the host of the new plugin or theme.

An alternative way of working for developers is working with his/her own local Dockerfile that will be build to pull the plugin for his/her own repository... but this will be significantly slower than the volume method.

Last but not least, those storage folders need to exist with the right permissions before you run your docker compose command or it will fail.

To be sure your volumes have the right permissions, you can run those commands:

$ chown 33:33 ./volumes -R            # Debian 33:33 / Alpine 100:101
$ chown 999:999 ./volumes/db -R
$ chown 999:999 ./volumes/logs/db -R

In other words... all the content inside volumes will be owned by "www-data" user and group (uid 33 and gid 33 inside the Debian container), execpt for db and logs/db folders that will be owned by mysql user and group (uid and gid 999).

Built in scripts

The Dockerfile includes some scritps at "/usr/local/bin" to facilitate common opperations:

ScriptContainerDescription
pkp-run-scheduledojsRuns php tools/runScheduledTasks.php. Called by cron every hour.
pkp-cli-installojsUses curl to call the ojs install using pre-defined variables.
pkp-pre-startojsEnforces some config variables and generates a self-signed cert based on ServerName.
pkp-upgradeojsRuns php tools/upgrade.php upgrade. (issue when config.inc.php is a volume)
pkp-variableojsReplaces the variable value in config.inc.php (ie: pkp-variable variable newValue)

Some of those scripts are still beta, you be careful when you use them. Let us know if you find any trouble.

You can call the scripts outside the container with docker compose exec`:

$ docker compose exec app /usr/local/bin/pkp-variable session_check_ip Off

Alternatively you can do the same with docker exec:

$ docker exec -it pkp_app_journalname /usr/local/bin/pkp-variable session_check_ip Off

Upgrading OJS

Thanks to docker, the ugrade process is easy and straightforward.

  1. Stop the stack with the old OJS version (for instance "pkpofficial/ojs:2_4_8-5").

    docker compose stop
    
  2. Set the new version in your .env file (or directly at docker-compose.yml)

    Replace the old version: 2_4_5-2

    with the new one: 3_2_1-4

  3. Pull and Start the container. As you changed the version, pull will download a new image with and up will automatically remove and create the OJS app container with the new code (remember that containers are not persistent).

    $ docker compose pull
    $ docker compose up -d
    
  4. Run the upgrade script to upgrade the OJS database and files. Easiest was is connecting to your OJS container with docker exec and run the ojs-upgrade built in script with this single line:

    $ docker compose up php tools/upgrade.php check && docker compose up php tools/upgrade.php upgrade 
    
    TIP: Discover your container name?
    You can see the name of all your containers with docker ps -a. The ones related with OJS will be something like ojs_app_journalname.
    Use grep to filter as follows: `$ docker ps -a

Before the upgrade you will like to diff your config.inc.php with the version of the new OJS version to learn about new configuration variables. Be specially carefully with the charsets.

WARNING: May I upgrade directly to the last OJS stable version?
It depends on your initial version. The recommended upgrade route is:
2.x > 2.4.8-5 > 3.1.2-4 > 3.2.1-4 > 3.3.x-x

Apache2

As said, right now the only avaliable stack is Apache2, so configuration files and volumes are thought you will work over an apache.

If you want to know the fastest method to set your own config jump to the next section "Easy way to change config stuff".

For those who like to understand what happens behind the courtains, you need to know that during the image building we ask the Dockerfile to copy the content of ./templates/webServers/apache/phpVersion/root folder in the root of your container.

It means, if you like to add your specific php settings you can do it creating a PHP configuration in ./templates/webServers/php{5,7,73}/conf.d/0-ojs.ini and build you own image locally.

There are some optimized variables already, you can check them within each version directory, e.g. /root/etc/apache2/conf.d/ojs.conf with your virtualhost or /etc/supervisor.conf... or, now you know what Dockerfile will do, you can add your own.

Again: Note that template's /root folder is copied into the Docker image at build time so, if you change it, you must rebuild the image for changes to take effect.

Easy way to change config stuff

If you don't want to keep you own local images, you can use the ones we build in dockerHub and map your config files in your docker-compose.yml.

So if you like to change something in (for instance) your php settings, you only need to created create a ./volumes/config/php.custom.ini outside your container and uncomment the volume in your docker-compose.yml.

Check the volumes section for a list of folders and files we think could be useful to overwrite or extend to fit your needs.

Restful URLs (aka. clean URLs)

By default the restful_url are enabled and Apache is already configured, so there is no need to use index.php over url.

SSL

By default at the start of Apache one script will check if the SSL certificate is valid and its CN matches your SERVERNAME, if don't it will generate a new one. The certificate can be overwritten using a volume mount (see docker-compose.yml file).

Note: This feature is under reveiw and could change in future.

SSL handled by an external service

If you have an external service in front handling SSL connections (often referred as SSL offloading or SSL termination) you need to add a new line containing PassENV HTTPS in ojs.conf, inside the main <VirtualHost *:80> section.

How could I help?

Update the compose configurations and Dockerfiles

If you want to join the docker-ojs (aka. docker4ojs) team you will like to contribute with new Dockerfiles or docker-composes. To do this, you will need to clone this project and send us a PR with your contributions.

Before we follow, let us clarify something: Versions of this project fit with OJS tag versions, BUT... if you take a look to PKP's repositories, you will notice the tag naming syntax changed at version 3.1.2-0. We moved from "ojs-3_1_2-0" to "3_1_2-0".

So, to avoid keeping in mind at what momment we changed the syntax, in this project we only use the modern syntax, so you cant/must refer every version with the same notation.

Said this, let's talk about how we generate all this versions:

The files for the different OJS versions and software stacks are generated based on a number of template files, see directory templates.

You can re-generate all Dockerfile, docker-compose(-local).yml, configuration files, etc. calling the build.sh script.

# generate a specific version
$ ./build.sh 3_1_2-4

# generate _all_ versions
$ ./build.sh

Add a new stack to the list

Let's say we like us to distribute a "nginx" stack. We have our hands full but you know docker and nginx so... ¿how could you contribute?

  1. Be sure the version number is in the versions.list file (ie: 3_2_1-0).

  2. Create the required files and folders in the templates folder.

    Basically you will need:

    • A Dockerfile template for each php version you publish (ie: dockerfile-alpine-nginx-php73.template)
    • A generic docker-compose.yml template (templates/dockerComposes/docker-compose-nginx.template)
    • A folder with all the specific configurations (templates/webServers/nginx/php73/root)
    • Extend exclude.list with the stuff you want to be removed.

    This is the hard work. Take apache as a reference and contact us if you need indications.

  3. Edit build.sh to add your version to the proper variables.

    For the nginx exemple (over alpine) it should be enough extending the webServers array:

    webServers=(  'apache' 'nginx' )
    

    Modify the script if you need it to be smarter.

  4. Run build script to generate all versions again:

    $ ./build.sh
    
  5. Test your work running docker compose with local dockerfiles.

  6. Commit a PR with your new build.sh and templates (ignore the versions folder).

Troubleshooting

I have trouble with Mac

In general with docker, there are some known issues with the new Mac’s ARM architecture : https://stackoverflow.com/questions/73294020/docker-couldnt-create-the-mpm-accept-mutex . Alternative solution (other than hardcoding mutex settings) might be to build docker image also for arm64 platform (https://github.com/bitnami/containers/issues/4679). Some work was started in this line in gitLab building pipelines with promising preliminary results.

I have trouble with Windows

Instructions to run are for linux (as fas as linux is the natural platform for docker and servers) but is also possible to run it in windows. The wget instructions use variables defined in the env-file but this is not compatible with windows powershell, so would be nice to find an alternative that works all platforms. As a temporary solution we add clear instructions for windows users, that need to modify the inliner to get the right version of the config.TEMPLATE file.

May I get an image based on nginx?

A nice addition for docker images would be offer nginx image to replace the existing apache2.

How could I deal with plugins?

One thing you always will need to deal with is plugins. This is now possible but could be improved with a few ideas that appear during the sprint as:

  • Use volumes managed with git
  • Create new ojs-plugins script helper that backups and download the essential release plugins for your version.
Is there any roadmap?

The project is build based on the needs of the participants. If you like to join, contact [email protected]. There is no formal roadmap, but we like to implement all the suggestion we made in the Containers for PKP document. Priorities right now are (by order):

  1. Fixing Mac image issues.
  2. Automatize docker images building and pushing to different repositories.
  3. Create new images based on "Containers for PKP" proposal.

License

GPL3 © PKP

Tag summary

Content type

Image

Digest

sha256:d1530e533

Size

487.7 MB

Last updated

18 days ago

docker pull pkpofficial/ojs:lts-3_5

This week's pulls

Pulls:

2,954

Last week