Skip to content

[Nextcloud] Add Play with Docker button #1034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

tilosp
Copy link
Contributor

@tilosp tilosp commented Oct 7, 2017

@tilosp
Copy link
Contributor Author

tilosp commented Oct 12, 2017

@tianon please review

@tianon
Copy link
Member

tianon commented Oct 12, 2017

That cron service is really hacky -- how are users normally expected to implement cron for Nextcloud, especially in a Docker context?

@tilosp
Copy link
Contributor Author

tilosp commented Jan 11, 2018

@tianon At the moment there are two ways. One is the hacky docker-compose one and the other one is this Dockerfile.
We could make the docker-compose way less hacky by adding the script to the container. And then just change the entrypoint in the docker-compose.yml for the cron container.

@tianon
Copy link
Member

tianon commented Jan 12, 2018

How about this?

FROM nextcloud:apache

# busybox's crond is more flexible than what's provided by the "cron" package
# (especially around logging)
RUN apt-get update && apt-get install -y busybox-static && rm -rf /var/lib/apt/lists/*

RUN echo '*/15 * * * * www-data php -f /var/www/html/cron.php' > /etc/crontab

WORKDIR /var/spool/cron/crontabs
CMD ["busybox", "crond", "-f", "-l", "0", "-L", "/dev/stdout"]

Combined with:

version: '3.2'

services:
  db:
    image: postgres
    restart: always
    volumes:
      - db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=nextcloud
      - POSTGRES_USER=nextcloud
      - POSTGRES_PASSWORD=nextcloud

  app:
    image: nextcloud
    restart: always
    ports:
      - 8080:80
    volumes:
      - nextcloud:/var/www/html
    environment:
      - POSTGRES_HOST=db
      - POSTGRES_DB=nextcloud
      - POSTGRES_USER=nextcloud
      - POSTGRES_PASSWORD=nextcloud
    depends_on:
      - db

  cron:
    image: nextcloud:cron
    restart: always
    init: true
    volumes:
      - nextcloud:/var/www/html
    depends_on:
      - db

volumes:
  db:
  nextcloud:

You could even simply include busybox-static with the pre-configured crontab in the base nextcloud image, and add a nextcloud-crond script which is basically just:

#!/usr/bin/env bash
set -Eeuo pipefail
mkdir -p /var/spool/cron/crontabs
exec busybox crond -f -l 0 -L /dev/stdout "$@"

So you'd just use:

    image: nextcloud
    command: nextcloud-crond
    init: true

(and init: true is only necessary if you want to be able to Ctrl+C to kill it interactively -- it seems to respond fine to the SIGTERM that docker stop sends without --init)

@tilosp
Copy link
Contributor Author

tilosp commented Jan 12, 2018

@pierreozoux What do you think?

@pierreozoux
Copy link
Contributor

I like the second option with the nextcloud-crond script and the different command in the compose, I find it nicer.
(yes, it was hacky, but still works :) also had a lot of trouble to find a nice crond script that was minimal for docker, but now I'll know! Thanks!)

@tilosp
Copy link
Contributor Author

tilosp commented Jan 12, 2018

Started to implement the second option in nextcloud/docker#220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants