friendica / docker

Docker image for Friendica
https://friendi.ca
GNU Affero General Public License v3.0
49 stars 19 forks source link

Cron instructions unclear / broken #142

Closed jgoerzen closed 2 years ago

jgoerzen commented 3 years ago

Hi,

The README.md discussion on cron lists three options.

"Using the default Image and activate the cron-job (see Installation, sector Activating scheduled tasks)"

However, since the default image doesn't include cron, nor a way to just fire up a daemon like that, none of the options in "Activating scheduled tasks" appear to apply.

"Using the default image (apache, fpm, fpm-alpine) and creating two container (one for cron and one for the main app)"

This isn't documented really; how does one do this? Is there a certain URL that must be pinged from the cron container? Is it enough to just mount the same volume in both images and use the "Activating scheduled tasks" options?

"Using one of the additional, prepared cron dockerfiles"

This implies a single image. I tried that, and it never ran the installation at all. So I suspect that is broken.

I'd really like to just do this within a single image. It seems silly to have a second one just to do cron.

I observe a cron.sh in the source tree, but nothing seems to call it.

Thanks!

jgoerzen commented 3 years ago

I also noticed that the supervisor example pulls from friendica/server:apache which doesn't seem to be getting updated anymore.

nupplaphil commented 3 years ago

I addressed some of your input at #148

However, since the default image doesn't include cron, nor a way to just fire up a daemon like that, none of the options in "Activating scheduled tasks" appear to apply.

I fixed the path in the README to the right Friendica installation tutorial. In fact, the first possibility is to manually executing the daemon after startup ..

However, since the default image doesn't include cron, nor a way to just fire up a daemon like that, none of the options in "Activating scheduled tasks" appear to apply.

I linked to an example how a cron instance looks like. You have to start a second friendica image (like for the app itself), but you use the entrypoint /cron.sh instead (have a look at https://docs.docker.com/engine/reference/run/#entrypoint-default-command-to-execute-at-runtime for further information about entrypoints)

This implies a single image. I tried that, and it never ran the installation at all. So I suspect that is broken.

Yep it's broken, but I had to completely remove it due incompatibility.

I'd really like to just do this within a single image. It seems silly to have a second one just to do cron.

This isn't the (normal) way how this image is designed. It follows the "one task, one container" principle. So for a productive environment, you currently need 3 container:

Even if I can use one container for both App and Cron, you still need another container for the database.

jclendineng commented 3 years ago

Im adding an entrypoint like this:

--entrypoint="php /var/www/html/bin/daemon.php start"

this doesnt work, what am I doing wrong? The command works fine if I issue it manually.

nupplaphil commented 3 years ago

@jclendineng don't execute the daemon manually per entrypoint, I was at this point already, that's why I introduced https://github.com/friendica/docker/blob/stable/docker-cron.sh

so try --entrypoint="/cron.sh" instead :)

scifijunk commented 2 years ago

Well, I don't know if anyone has it running on Kubernetes like I am so here it goes. I finely got the Friendica Cron container running with the following Kubernetes file format (be it with or without Portainer being used):

apiVersion: apps/v1
kind: Deployment
metadata:
  name: cron
  labels:
    name: cron
spec:
  selector:
    matchLabels:
      octopusexport: OctopusExport
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  template:
    metadata:
      labels:
        name: cron
        octopusexport: OctopusExport
    spec:
      volumes:
        - name: friendica
          persistentVolumeClaim:
            claimName: friendica-f8400c86-d7cd-4a13-a8c0-1c57a74a3885
      containers:
        - name: cron
          image: 'friendica:stable'
          command:
            - /bin/sh
          args:
            - /cron.sh
          env:
            - name: MYSQL_USER
              value: USER
            - name: MYSQL_PASSWORD
              value: PASSWORD
            - name: MYSQL_HOST
              value: HOST
            - name: MYSQL_DATABASE
              value: DATABASE
          volumeMounts:
            - name: friendica
              mountPath: /var/www/html

Please note that USER, PASSWORD, HOST, and DATABASE would be where you put in the values you used for the MariaDB/MySQL container you set up for Friendica App container. You would also need to change the claimName to match the one being used by the Friendica App container. This is also based on a Kubernetes YAML Generator that I used at https://k8syaml.com/. Some of the config might not be needed but this is what I used to get the Friendica Cron container to work.

Hopefully, this helps when it comes to Kubernetes.

nupplaphil commented 2 years ago

Can you add your working kubernetes config as PR? I'm curious about it and would like to add it at .example/kubernetes

nupplaphil commented 2 years ago

Closing this issue, @jclendineng don't hesitate to reopen it again in case you need/want support Thanks @scifijunk again for your PR :)