Early draft of a docker compose deployment


#1

We have just managed to finish a Docker-only of OFN at https://ofn.allmende.io
It is built from https://github.com/allmende/ofn-docker
A lot of inspiration about what to do came from


It still misses configuration of a cron container and a setup for the delayed_job, as well as usage of OpenStreetMap instead of Google Maps.

Please also note my comment to this pull request:


Ansible deploy on debian / docker
#2

Hi @almereyda, looks interesting! Could you please comment a bit on how you see this in relation to the ofn-install project? Are you proposing it is a useful companion approach, a replacement, etc?

@maikel your thoughts on use of Docker welcome.


#3

FYI, I’ve increased the number of links and images a new user can post.


#4

When we worked on it yesterday night, our intention was not to replace anything but to provide another way of deploying production environment (than the ansible solution), straight from a dockercompose file.
I can hear the critics on Docker, but we believe multiple solutions is key to enhancement, so why not a Docker recipe.

It still miss some documentation (especially on assets compilation aka assets:precompile:primary && assets:precompile:nondigest .


#5

Do you have a tutorial for installing OFN using this Docker config?


#6

Kitematic is a good first place to start because it allows you to turn on
and off test docker machines. I agree it could help get more developers
involved

Greg


#7

Cool. Thanks for your contribution. I agree that it’s nice to have an alternative. But it will also increase the maintenance work.

A very successful project using Docker is Discourse. That is the only one I have worked with so far. And I did come across some difficulties with disk space. It’s also not ideal that some configuration changes require a rebuild of the container which involves downtime. I guess you could work around that, I just followed the official instructions.

I’m looking forward to having an alternative and hope that it will mean improvements of the Ansible scripts as well.


#8

We will get back to writing documentation soon’ish.


#9

Would that mean I can direct my programmer to Docker if I get one to volenter to contribute?


#10

@JozeHladnik for development setup I started modifying @almereyda composer file, you can find my current version here: https://gitlab.com/hackers4peace/ofn-devenv (it has some OSX specific stuff, I’ll make Linux variant as well)


#11

This looks very modular and flexible!

@almereyda Did you get memcached working? Linking a (standard image) container (in the same way like postgres) results in ‘dalli’ gem not finding memcached expected at localhost:11211
It seems to work when adding the container/host name in config/environments/production.rb like this: config.cache_store = :dalli_store, ‘memcache’

What is the docker compose way to configure the memcached host?

bundle exec rake assets:precompile:primary
results in: rake aborted!
Sprockets::FileNotFound: couldn’t find file ‘angular-rails-templates’

@pmackay Could this have to do with symlinking assets into public? https://github.com/openfoodfoundation/ofn-install/blob/master/roles/deploy/tasks/main.yml#L48-L57


#12

@jozelHladnik Docker allows all of us to run a copy of the live software so
that bugs and new solutions can be worked on by a bigger group

g


#13

Docker for production?

I was asked what I think about Docker for OFN production servers. So I’m sharing my thoughts here.

I totally get the point of having a virtual environment for development. Even though the OFN works on Linux and OSX natively, it would enable Windows users, it would keep environments separate, it would be a good place to test staging and production environments locally and so on. It would actually be good to document a list of advantages and disadvantages somewhere as a reference.

And then there is a good point in saying: “If we use Docker for dev and testing, why not use the same environment in production?”

But I think:

  • We have one VPS per OFN instance at the moment. So you have your own environment already.
  • We have a well working provisioning with Ansible already. We even have a configuration management there so that everybody knows which servers there are and which settings they use.
  • We would still need a provisioning tool like Ansible for the Docker setup on the server.
  • Docker is an additional layer adding more complexity.
  • Software updates (e.g. nginx) are simple to install on a VPS. They affect all native apps installed and they are permanent. With Docker we would need to rebuild/replace all containers.
  • It’s a good practice to keep the OFN software flexible enough to work in multiple environments, not just the default OFN Docker image.

Summary: I don’t think that Docker is ideal for OFN production use. But it is great to emulate a production environment on another machine.


#14

@maikel Thanks for those interesting remarks!

I was thinking of docker to be that VPS for me. Maybe that’s my misconception?

My server runs debian. The ansible scripts require some ubuntu dependencies (that I could not figure out how to install). That’s why I used a docker ubuntu image which worked fine (almost).

There is a wordpress site and some nodejs apps already running on that server. Nginx is (virtual multi host) configured to distribute incoming http requests between them. I tried to install an OFN instance beside that. How would you do that? Simply renting another vps? possibly switching the hosting provider to find one that offers the fitting ubuntu version?

Do you think it would be a good idea to share the nginx and postgres db that is already running? Docker-compose seemed to “promise” that by modularizing the different os processes. This would also enable to upgrade, replace or reconfigure them separately without having to run that huge ansible thing again which contains everything.

I’m not a sysadmin. Just trying to figure out how to set up OFN.


#15

Thank you for sharing the background. That helps me understand your situation.

I was thinking of docker to be that VPS for me.

Okay, cool. It’s a good solution to create a separate environment. It saves you renting another VPS and lowers your costs. Great. More environments just means that you have more systems to take care of and to keep up-to-date.

My server runs debian. The ansible scripts require some ubuntu dependencies

Debian is my favourite. :slight_smile: Ideally, we would make the Ansible scripts general enough to work with Debian as well. That was the idea behind Ansible. And it’s not that difficult. It just hasn’t been a priority, because people just chose Ubuntu.

In the meantime, it’s a good idea to use Docker as a compatibility tool. That’s a strength of Docker. But wouldn’t it be better if we didn’t need Docker? That was the point I tried to make.

There is a wordpress site and some nodejs apps already running on that server.

We do the same on openfoodnetwork.org.au (OFN) also running openfoodnetwork.org (Wordpress). The difference is that it’s Ubuntu. We just have several configurations listening to different server names. The OFN config accesses the Unicorn processes (started by an unprivileged user) via FCGI. That’s how the Ansible scripts set it up.

Do you think it would be a good idea to share the nginx and postgres db that is already running?

I don’t know if it’s a good idea. We do it that way. I guess it’s more efficient and that’s why database software supports multiple databases and multiple users with access management.

Another summary: I think that Docker is a great tool. And I think you made a good decision to use that tool to get the OFN working in your environment. But I also think we should make the OFN compatible with any setup people want to run. It should make the OFN cleaner, more flexible, faster and more powerful. But that’s just my opinion. We also have to be careful that the OFN doesn’t become full of workarounds to live in every possible environment. What are your thoughts, everyone?


#16

wouldn’t it be better if we didn’t need Docker?

fully agree! Initially I just manually set up a rails environment on my laptop which worked fine (although this might be more difficult if you’re not used to rails). Then I tried the (awesome) ansible scripts on the server and documented the experience here Ansible deploy on debian / docker The only reason to use docker had been the ubuntu dependencies.

make the OFN compatible with any setup people want to run

That’s what docker - how I understood it - promised to do: make OFN run anywhere by just running a ready build image inside an isolated (movable) container. I was really inspired of how simple and quick(!) it was to setup wordpress in seconds: docker-compose up -d and done. The whole “setup” is isolated and can easily be moved to another server. The ansible scripts have been rather slow and it took a lot of attempts until they finally ran through. Then I tried docker commit and thought this would save all the work… but it didn’t. After running the committed docker image on my local machine it was necessary to start nginx, postgres, unicorn, memcached services manually and I couldn’t get the background job runner to work (…) Probably I was doing docker wrong :confused:

be careful that the OFN doesn’t become full of workarounds to live in every possible environment.

Very true! Keep it simple. I’m not excited about docker the tool. I’m excited about the promise to quickly spin up OFN instances and being able to easily stop/start an instance or move it to a different machine. Maybe docker container is not the right tool for this? @enricostn talked about plain linux containers LXC. Any thoughts about that?


#17

I was talking about using LXC for development environments, not production.

Regarding your case, re-using an existent VPS with other distro than Ubuntu, maybe you could contribute on adding Debian compatibility to ofn-install repo. Sharing same nginx and DB can be an option, but outside of ofn-install IMHO.


#18

I want todo install OFN in a debian laptop. Can i use this docker?
Do You have a guide?
PreRequistes, etc.


#19

If I had got ofn running on debian I would (happily) contribute it @enricostn . But I gave up after two days. IIRC there are just some language l10n packages that are missing on debian and I could not figure out how to install them. Probably only minor issues @Rulosanti but I went with an ubuntu docker container at the time (which I can not recommend […]). The easiest is imho to “simply” use an ubuntu 14.04 VPS