markshust / docker-magento2-php

This image is built from the official php repository and contains PHP configurations for Magento 2.
MIT License
52 stars 61 forks source link

crontab missing #1

Closed pantaoran closed 8 years ago

pantaoran commented 9 years ago

Wouldn't this container need to have crontab installed? I'm exploring Magento 2 and it seems that a lot of stuff is done through cronjobs, so I wanted to set one up but got "crontab: command not found". Also, how about setting those cronjobs as part of the container already?

http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html

markshust commented 9 years ago

This is a dev container that is also a WIP. I'll definitely take PR's :)

pantaoran commented 9 years ago

I will consider creating one.

markshust commented 9 years ago

There is a series of tasks that should be created to start forming a production-ready image. This includes: memcached container config, cronjob container, separating frontend and backend routes, etc.

So along these lines, the cronjob should run in something like a one-off container, or since it runs every 5 minutes, just a streamlined php image, so the cronjob tasks don't run on the same containers as the frontend servers and can be scaled separately.

markshust commented 8 years ago

Added crons to php image, but note this is just temporary until a better solution is in place. These should really run in one-off containers on a schedule, or on their own designated container so multiple cron processes aren't run more than once.

pantaoran commented 8 years ago

I'm coming back to another old topic that I have been ignoring for too long...

I noticed that actually my cronjobs never run even though I configured them inside the php container. I also found this issue which I think makes a lot of sense. What's your position on this today? In #24 it sounds like you actually had running jobs, although that is hard for me to imagine at the moment given above information.

What do you mean when you say

These should really run in one-off containers on a schedule

because I've been thinking about this but I don't see how a container could run commands inside another container...? Maybe I'm confusing myself here.

markshust commented 8 years ago

Crons have just been fixed, see https://github.com/mageinferno/docker-magento2-php/issues/24#issuecomment-235487100 for the appropriate images where crons are running.

This is a temp fix but should work just fine. Following a true 12-factor app process, crons should run in their own containers. But you don't need to really worry about this right now.

pantaoran commented 8 years ago

Ok after downloading your image and looking at the running processes, and reading your scripts I now understand what you're doing. But I think this is a somewhat dangerous way to do it.

I only have one process running in my container (php-fpm-master), so when for some reason that crashes, the entire container exits, making it obvious that something has gone wrong.

In your case, when the php process crashes, the container will stay alive due to the running cron process, and it's not necessarily clear that something has gone wrong. You're violating the "one container - one process" docker philosophy.

markshust commented 8 years ago

This is not dangerous, it's a quite common method of setting up crontabs.

I don't want to get into specifics here, but there is no 'one container - one process' philosophy (at least I've never followed one). There is however a 'one container - one service' philosophy. It's important to know when to branch off containers and when not to, but the current setup should suffice for now. There are other images that even run php/apache on one image, and this also doesn't break the docker philosophy. That said, it should't be hard to build one-off containers for cronjobs (just move the cron start process to a new image, and make that the main RUN command). I want to do this, but I have no time. I'd be open for a PR for this, however the current implementation is the best I can do on my timeframe.

There are a lot of opinions about this docker architecture, but not very many pull requests, and hardly any that I merged in. These docker images take a lot of time. If someone wants to contribute, I'd be all open for it, but they have to match the code style & format of the other dockers images and be fully test, etc. before I would create and/or merge them in. You're also welcome to build custom images for your own purposes (given that there are over 15k pulls on these images now, I can only assume a lot of people are already doing this).