Docker4ojs: A set of docker images for OJS

ojs
docker
development
production
docker4ojs
Tags: #<Tag:0x00007f1274545c80> #<Tag:0x00007f1274545b40> #<Tag:0x00007f12745459d8> #<Tag:0x00007f1274545898> #<Tag:0x00007f1274545758>

#1

Hi,

It’s a fact that Docker and Vagrant are today mature enough to be taken in consideration.

I don’t want to start here a discussion about which one is better… both have their lights and shadows, but I like docker I started a few experiments to see how useful is for DEVELOPMENT but also for PRODUCTION environments.

When I started I noticed two existing projects, although a little bit outdated, help me to understand how to start:

If the developers are here, they are very welcome to comment, contribute or criticize. Thanks a lot for your work.

First one (@arturluizbr) is much cleaner and build the application from github, but it’s also a little bit constrained.
Second one (infrascielo) is much complex but suited for an specific context and get the application from the official tarball.

Git gives us much more control and fits very well with docker-hub automation tools so I decided to start my work from the first one. I also took a few ideas from infrascielo image and I extended them all with docker-compose.

Here you have the preliminary results: https://hub.docker.com/r/marcbria/docker4ojs/

Right now I’m focused in discover if this is really suitable for a production environment, with hundreds of journals, with a preset or testing DB, with a single nginx, backup/recover/snapshots, centralized logs, monitor, mojo…

But main question now is this:
https://stackoverflow.com/questions/41883605/multiple-docker-containers-for-mysql-or-one-instance-with-multiple-databases. Multiple mysql (or mariadbs) are winning.

I’m also worried about how to offer a “cute” frontend to all this stuff. My initial suggest https://portainer.io (you can run it as a container and won’t brake nothing in your host). So, a portainer OJS template is also in the toDo list.

I forget to mention this project is inspired by docker4drupal. Great ideas shown there still need to be reviewed and adapted. Any help and comment is welcome.

Cheers,
m.


#2

Hi all,

Excellent work so far, @marc! Since you mentioned Vagrant – and not to dilute this thread, hopefully – there is also a Vagrant configuration for PKP software.

I like the idea of keeping the database containerized as well.

Regards,
Alec Smecher
Public Knowledge Project Team


#3

Thanks to point Alec. I took a look to vagrant, but, I always thought LXC was a good idea.
Apart of the hype and the criticisms, let’s see how stable and mature is Docker.


#4

Back to the main topic, I have been reading what people is saying… Here you have a few links from 2017 categorized.

I will update this list with new stuff if I think it could be useful.
Please, feel free to recommend me more readings…

Remember the goal is build something useful for DEV and PROD, entirely based on free software (no external dependences).

My preliminary conclusions (in short):

  • Right now looks like docker can work really well for development. Lightweight containers that include all the need dependencies that could be shared. Great for testing existing work, or to deliver demos, or to deliver translators a place to work, but it’s magic to see how the app could react over new stack (mariadb or php versions…).

  • From the production perspective, where docker is great is is rising processing containers. I mean, you can also set them in a array, to implement High Availability Clusters, but lacks in storage. Lot of people recommends avoid volume containers, even not storage data in containers, to avoid data lose.

What to do?

There are 3-4 orchestration tools that promise to do all the work for you, but I don’t want to give the control of my applications to a tool I don’t know or understand, so my approach is going form the simple to the complex.

My initial goal was building an image (Dockerfile) that could be called from a docker-compose.yml based on an external configuration file (.env), but environment are tricky when you want to autobuild your images in DockerHub and I didn’t succeed.

I’m working in 3 different branches:

  • latest: For developers (may be it need to be renamed to DEV). Get code from ojs git (master branch) and keeps git installed to let you apply patches. Extra dev tools could be added.
  • production: For sysadms. Magic is done in docker-compose. I still need to include a lot of stuff there (logs, backups, docker-entrypoint-initdb.d, mojo…) and see what happens when the machine is overwhelmed or 3rd-party containers fall down.
  • experimental: Is where I’m playing with docker options to see what is possible and understand how it works.

I made some preliminary research about the official images, but it’s too early to make a recommendation to PKP:

I will follow working in how to preset ojs (docker-entrypoint-initdb.d) for demo or a base site.


#5

@asmecher I follow your suggestion and the last days I dig into docker/docker-compose to build a service stack based on a singleDB but I feel like we are going against the tool with this approach. I mean, while with a separate db-container for each journal (multipleDB) everything was easy and clean, when I tried to build something with a “singleDB” I noticed complexity grows.

I mean, singleDB it’s possible but not as beautiful and simple and I think this is mainly because docker philosophy is based in “isolation” and with a shared DB model breaks with this.

Apart from this, I can’t see the benefits of a singleDB and I like better the multiple instances because of:

  • Performance: It’s more or less the same… even in some specific cases could be better with multipleDB,
  • Backup: you only lock a single DB each time.
  • Monitoring: with a singleDB is more difficult to trace what journalDB is eating the resources.
  • Dev & Prod: Keep the same architecture for dev and prod.
  • Simplicity: Docker offers a few tools to “link”, “initializeDB”, that are simple to use in the multDB model.

Am I missing something?


#6

Hi @marc,

Ah, I see by a quick Google around on the subject that my first hunch doesn’t align with Docker’s philosophy and practices for other apps (e.g. Wordpress). I’d suggest following standard practice, which in this case looks like a link to an existing (outside OJS’s Docker container) MySQL install.

Drupal might offer the best concrete example, since it also supports both MySQL and PostgreSQL.

Regards,
Alec Smecher
Public Knowledge Project Team


#7

Guys, i would like to say that i’ve finished one new docker with more extensive documentation, and i used lots of the tar.gz builder to build the docker, it its lightweight and has all things need to production use, if you wan’t to check it out: OJS Docker

I’m just making some ajustments to build all versions automatically, like one container peer OJS git tag.

Thanks 4 all.


#8

Hi @lucasdiedrich,

Excellent, and thanks for the heads-up – I’ve passed this along to a group that’s currently experimenting with docker for OJS hosting.

Regards,
Alec Smecher
Public Knowledge Project Team


#9

Awesome, i’ve created tagged builds containing latest version of 2.x and
3.x, you can check at: TAGS
https://hub.docker.com/r/lucasdiedrich/ojs/tags/

Thanks,


#10

Hi @lucasdiedrich

Sorry for the silence. I was on xmas vacations… and I’m starting to clear out my inbox.

I took a fast look to your work and I need to say that I’m impressed: Alpine was on my toDo, but you documented the Dockfile very well with some ENV variables and useful scripts… but building from git based on buildpkg.sh script is really smart solution. Great job. Thanks.

Let me a couple of days to test your dock and compare with my former work to suggest improvements (if any).

BTW, do you have any experience setting official repos in docker hub? Looks like the natural steep now. Are you interested in keeping this repo up to date?


#11

Hi all,

Just a note that I’ve run into another long-forgotten Docker config for OJS:

Not sure if there’s anything useful there, but linking it in.

Thanks,
Alec Smecher
Public Knowledge Project Team


#12

Yes… I know about this one. It’s the first you find in docker hub when you are looking for “pkp ojs” containers.

I based my first Dockerfile in his work but it’s quite old and @lucasdiedrich work is much better.

Scielo also worth a look (not based on git, but good use of ENV variables):
https://hub.docker.com/r/infrascielo/pkp-ojs/

Here you have a list of all the ojs docks published in docker hub:
https://hub.docker.com/search/?isAutomated=0&isOfficial=0&page=1&pullCount=0&q=ojs+pkp&starCount=0

Is not published in docker hub, but @axfelix also implemented a Dockerfile for ojs:

I think we need to unificate all this work and deploy an official Dockerfile that could be used for development and production sites.

@asmecher what do you think?


#13

Hi @marc,

Yes, absolutely! It would be great to be able to point to a single “official” resource for this.

Regards,
Alec Smecher
Public Knowledge Project Team


#14

Hi @marc,

There still some improvements that we can do, add more environment variables or cli installation, add supervisor to manage apache ( this idea i saw over axfelix image), and some other stuff.

But to make this i think we should first create and oficial github project, maybe you can fork my project into pkp github domain, and then we can manage the improvements over issues. Later we can create and oficial repo over hub.docker.com

What do you think?


#15

@asmecher I reviewed all the existing Dockerfiles and IMHO Lucas’ is the most promising on, so I’m ok with the suggested roadmap.

@lucasdiedrich does it means that you are offering yourself to lead and maintain this? :wink:

Some comments about your last post:

  • supervisor sounds also like a nice idea.
  • What ENV vars do you miss?
  • As far as I know, there is no “cli installation” script for OJS, so in past I did this “sed-ing” over the SQL dump of a clean “pre-installed” database. I worked a little on this over a bash script called docker4ojs (aka. dojo). This script was developed to keep a farm of OJS.
  • I will also add “treafik” to the wish list. I’m working on this right now.

Cheers,
m.


#16

Marc, i’ve added some issues to optimize the docker image, i’m going to
make a sprint dev this week to optimize it. I’m thinking, can you point out
someone who can validate for me the apache packages installed over the
image?

I’m thinking there is to much apache/php libraries installed, it all of
then necessary?

Thanks.


#17

I will take a look but @asmecher is the best person for this job. Nobody knows OJS like him.

Alec, here you have the dependence list:

PACKAGES=“dcron apache2 apache2-ssl apache2-utils php5 php5-fpm php5-cli php5-apache2 php5-zlib
php5-json php5-phar php5-openssl php5-mysql php5-curl php5-mcrypt php5-pdo_mysql php5-ctype
php5-gd php5-xml php5-dom php5-iconv curl nodejs git” \

In the other hand @lucasdiedrich I recommend moving your entire ENV section to an .env file.
EXCLUDE var is hudge and taking all this info out will make your Dockerfile much more readable.

Please, keep us informed about your advances.

Cheers,
m.


#18

Hi all,

This looks like excellent work – thanks, @lucasdiedrich and @marc and everyone else who’s contributing here.

I’ve reviewed the dependency list against the Travis scripts, which are responsible for setting up a working git install of OJS from a fairly basic Ubuntu VM. The only packages I don’t see listed here are php5-intl and php5-xsl. (These may or may not be necessary for PHP7 – IIRC they’re needed for PHP5. If they are available, no harm in installing them, I think.)

Regards,
Alec Smecher
Public Knowledge Project Team


#19

@lucasdiedrich sorry for the silence. I was kind of overwhelmed with different fire fronts. Any update about your work? Do you need help?

I’m finishing my upgrade script inside dojo (docker4ojs helper).

If you finished your Dockerfile please advice us so we can take a second-deeper look and we start talking if it must be moved to pkp’s github domain (to be clear: I say yes, but I’m not the one that takes the decision :slight_smile: ).

Cheers,
m.


#20

UPDATE:

I modified dojo (a bash script to keep a farm of journals) to work against luca’s Dockerfile (more lightweight and smart than all the other attempts) and now is working like a charm.

Now I like to extend my base docker-compose with (at least) treafik and HTTPs so I will keep working on “docker4ojs” for a few weeks.

My intention is testing it all in production, for a single journal… after Easter’s vacations or so.

@lucasdiedrich please, let us know if you finished your work with your Dockerfile for a second testing round.