selfoss icon indicating copy to clipboard operation
selfoss copied to clipboard

Docker Container

Open MatthK opened this issue 1 year ago • 2 comments

Not an issue at all, but also not sure where else I should put this.

For anyone looking for a docker container, this one here should be working. It works out of the box with the sqlite db, but it should be possible to link it to an existing other database as well.

You can find it here: https://github.com/MatthK/Selfoss-Docker

MatthK avatar Jul 22 '22 03:07 MatthK

Thanks. I am still not sure how to create Docker image properly so I am thankful for the inspiration. This seems somewhat cleaner than the other PR https://github.com/fossar/selfoss/pull/1170, relying on cron rather than trying to run the update periodically on its own, but I still have unresolved questions before being able to make an official one:

  1. Should we use Apache, nginx or lighttpd? Probably does not matter.
  2. Is it possible to use PHP-FPM in the same image as the web server, or do we need docker-compose? I am not really sure how people usually use dockerized apps – do they run any provided commands or do they use some other app to manage the containers that might only provision a single container from a single image (and thus dependencies on different containers for database and PHP-FPM would be painful)?
  3. What is responsible for restarting the web server, e.g. if cron, apache2-foreground or php-fpm worker (if we introduced one) crashes? It would be nice to have systemd manage the services but AFAICT, only Podman has sort of support for systemd.
  4. How do we handle logging? What about configuration?
  5. Do we need a different container for development? It might simplify onboarding of new contributors but I would not use it and other contributors are few and far between so I worry it would bit rot quickly.

By the way, if you want to speed up the build a bit, you can use the pre-built image (and you will also get a guarantee of CI passing on it):

version=$(curl https://dl.cloudsmith.io/public/fossar/selfoss-git/raw/index.json | jq '.packages | max_by(.upload_date) | .version' --raw-output)
url="https://dl.cloudsmith.io/public/fossar/selfoss-git/raw/names/selfoss.zip/versions/${version}/selfoss-${version}.zip"

But then it will be harder to re-use for development.

jtojnar avatar Jul 22 '22 11:07 jtojnar

I fear I'm not that much of an expert on Docker either. I previously made a container to have my webfront with Selfoss in one container. Recently someone asked, if it would be possible to update Selfoss to the latest version, to take advantage of the latest features. So I experimented and got this up and running.

I then created this build to have Selfoss only, in case someone didn't want my webfront included.

  1. I agree that it doesn't really matter. Seems to be more personal preference which webserver is the best for the job. I based my image on another example, and just took over Apache.
  2. There is a PHP-FPM image using FROM php:7.4-fpm. I guess the webserver would have to be added then separately with an apt install. Alternatively, here is a description of setting up an nginx and php-fpm image: https://blog.ruanbekker.com/blog/2017/08/26/building-a-alpine-nginx-php-fpm-image-on-docker-for-php-applications/
  3. I believe a Healthcheck can be used to verify if the container is running fine (or not and restart)
  4. You can define volumes in a container. That way you point to a directory outside the container to keep config and data persistent, even when the container gets deleted
  5. Not sure about that.

MatthK avatar Jul 23 '22 07:07 MatthK