-
Notifications
You must be signed in to change notification settings - Fork 200
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
Better Docker support #252
Conversation
…ce runner (cron + app in same container). Added healthcheck to docker-compose file, simplifying docker instructions. Moved database into docker-compose from overrides, since its required for application startup.
Pinging recent committers: @tommeagher @GabeIsman |
Hey @AnalogJ, Sorry, missed this when you first submitted it. Thanks so much for taking a crack at improving our Docker support! As you have correctly surmised we don't use Docker and we're not well-equipped to support it. The Docker support that does exist is the result of enterprising contributors like yourself. So I'm inclined to just trust that you've thought about how this should work and merge it. From what I understand about Docker, it looks great! My main question is this: If someone were already deploying Klaxon with Docker, would this change mess them up in some way? Or would the upgrade be smooth? Basically, how much do we need to communicate that the Docker setup is changing? I'd be super happy to have a Klaxon image on Docker hub, and even happier if you'd be interesting in helping us get that set up! Thanks so much for contributing! |
Thanks for taking a look @GabeIsman ! Looking at how everything was configured prior to my PR, I don't really see any real conflicts for existing users of Docker. The only thing I'd be concerned about would be the Adding an official docker build is pretty easy, the Docker hub docs are pretty good but they make it more complicated than it is, and they don't have any screenshots. Basically I would just do the following:
If you want, you can add me as member of |
Hey @AnalogJ, If you wouldn't mind setting that up for us, that would be amazing. I've added you as a collaborator on the repo. Let me know if you need any more specific access. Thanks for much for pitching in to make Klaxon better! I'm going to merge this PR now and hopefully cut a release later today! Gabe |
Hey @GabeIsman
We have two options here:
Sorry, about that. |
No worries, thanks for sorting through this with me. Turns out I did have a docker hub account (gabeisman is the username). Feel free to add me to the organization and I'll make sure the github org is linked to the docker hub org. Thanks! |
@GabeIsman done, you're now an owner. You'll need to go to https://cloud.docker.com/u/themarshallproject/settings and scroll down to the Linked Accounts section, then click Once that's done, I should be able to continue wiring everything up. |
Hey @AnalogJ , Sorry it took me a while to get back to this. I believe I've set everything up in Docker hub. Want to take a look and make sure it looks OK? Thanks again for helping with this! Gabe |
Looks good @GabeIsman !
Looks like the master branch is broken, but that's expected. I triggered a build of the |
@AnalogJ @GabeIsman I only now saw this, but re: whether this would bust Docker installs if you were already doing it — it's not ideal for us. 😬 We already had a way to run the cron job. (We're using this within Kubernetes.) This means we no longer have control over the frequency, making this a deal breaker for depending on the Dockerfile here. 😞 It's at odds with Docker to have the cronjob running within the container — scheduling is typically the job of something outside the system (cron on the instance you're using Docker, or within a orchestration system, etc.) so a single container isn't responsible for everything. This now means that if you're in a scenario where you spin up multiple instances of Klaxon (which we were) you're also spinning up multiple cron jobs (one for each instance). What's done is done, but I think it may have been better to handle this by documenting how to schedule tasks taking advantage of Docker instead of pushing it inside the container. We were already maintaining a fork and will continue to do so (and will just pull this stuff out), but I do think it's not ideal and kind of a surprise. |
Hey @rdmurphy, sorry to hear this is at odds with your setup. I've never deployed a production system with Docker, so I'm totally unfamiliar with the best practices. If you feel like we've gone awry with this setup, I'm happy to reconsider, I just don't have the expertise myself. So I'm depending on all you Docker users to guide the Klaxon Docker support. What are your thoughts @AnalogJ? Does it make sense to just document ways to schedule the task and remove the cron job? Maybe an environment variable could be added to disable the cron as a compromise? I do think that having the cron job run automatically is probably friendlier for first time users. But the Heroku setup is geared to ease of use for first timers, so I don't necessarily think the Docker system needs to maintain the same goals. If someone prefers Docker they are probably much more prepared to schedule their own tasks. |
I'll make it work either way! I totally understand the desire/need to try and make it as smooth for all kinds of users. 😅 I think @AnalogJ did a great job. Some thoughts on how to manage it in a Docker world: I think it's safe to not assume everyone is gonna run Klaxon in a massive managed system like Kubernetes, so whatever is the answer needs to help with the simpler use cases. Typically when I had access to the ability to run I think a flag would be acceptable and an okay compromise, but I'd probably want them for the migrate and create_admin calls too. I think what's most difficult about the addition of all the scripts to the Docker container is that it makes a lot of assumptions about your environment. For example, in the current state you cannot run the container without it attempting to run a migration. You may not always want that! |
While I don't completely agree with the premise that "Docker must run one process, and only one process", I do understand the concern about controlling the cron schedule. It should be pretty easy to make the cron service optional. Having said that, if you don't want to manage cron outside of docker, but you want to change the frequency of the cron task, the While my goal with this PR was to significantly decrease the friction for new users launching Klaxon, I knew that existing users were managing the cron task somehow, so some turbulence was expected. I'll work on a PR to add individual environmental flags for the rake tasks and the cron service. |
I'm not super strict about the "one process" thing either, but IMO this should have been done in a fork for the Portainer use-case, or as a separate image that comes with "all-in-one" support instead of changing the primary image to better suit a specific deployment platform and its limitations. It could even extend the primary image and happily co-exist with it. The flags are gonna add even more complexity here (and the current additions/escape hatches aren't documented at all). Perhaps having the base image and an "all-in-one" image is something we could consider? |
Hey there, our set up looks similar to Ryan's. We're running Klaxon on Kubernetes using this Helm chart and an external cron job definition. Running the check in a separate container preserves our ability to scale and improves reliability. We've got a forked image we've been building, this'll probably keep us on that. Though we'd love to use the official image in the future. |
Hey,
First of all, this project is awesome, and I appreciate all the hard work you've all put into it. Its been incredibly valuable for me.
I make heavy use of docker for managing applications on my server, though I've read in other issues that Docker is not how your team deploys Klaxon in production.
I've made a couple of tweaks to your docker-compose.yml & Dockerfile that greatly simplifies the startup process for any of your users using Docker. It's just
docker-compose up
now.Here's a list of changes I made:
bundle exec rake check:all
every 15 minutesI'd love to see some (or all) of these changes merged into mainline master, so I can delete my version.
In addition, I'd love to see an official automated build setup on Docker hub (I can help with that if you're not familiar).