Skip to content
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

Remove apache from the image and run a unicorn instance #10

Closed
wants to merge 1 commit into from

Conversation

AdrianRibao
Copy link

Hi,

I think you have done a great job with this docker image. It has been inspiring and I've learnt a lot about how to create docker images properly.

I have my current redmine installation running with unicorn, and I like it, so since I'm learning docker, I thought it could be a good idea to modify this project so that instead of running with Apache, it does with a unicorn process.

I don't know ruby, I'm a django programmer so I have little experience with RoR environments, and as I said before, I'm just learning docker.

I don't expect you to incorporate this changes, just share with you my work, and learn more about it.

My goal is to modify the project so it also accepts postgresql databases. I'll work on that next.

@sameersbn
Copy link
Owner

@AdrianRibao I myself am not a rails developer. When I discovered docker I created this image to learn docker and over a period of time I was able to fully package redmine into a docker image.

Your work is good, I would like to know what is the benefit of using unicorn over using apache? I am sure it has its benefits. If you could install nginx and proxy port 80 connections to the unicorn processes then I would be willing to merge this change to the master.

@sameersbn
Copy link
Owner

@AdrianRibao also note that the current image uses memcached to improve the applications performance. Will these changes keep the performance improvements coming from memcached?

Regarding the postgresql support. It will be really trivial for me to add it as my docker-gitlab image already has postgresql database backend support. Do you want me to add this support or do you want to add it yourself as an exercise?

@AdrianRibao
Copy link
Author

The benefits are:

  • a lightweight image
  • I think it's faster than passenger
  • Containers are probably run behind a proxy so we don't need one more webserver in the middle
  • Highly configurable (we can add customization in the image in the future)

About the postgresql support:
I've created a branch: https://github.com/AdrianRibao/docker-redmine/tree/postgresql that has postgresql support.

I wanted to show you this branch, but I think I did a mistake because instead of just adding PostgreSQL support, what I did was: Remove Apache and use unicorn (this branch), and start postgresql branch from this one. So I cannot show you the changes isolated from the code of removing apache.

Also in my postgresql branch, I removed mysql and used sqlite as a default database. So the image it's even lighter. And fixed a small issue with memcached that has to be run using "-u root"

I'm going to send you a pull request from that branch so you can see the changes, but you can discard it and use the code you find useful, no problem about that, it's my fault I didn't organize better my branches with better isolated changes.

Also the documentation has not been altered yet, I'm not a native English speaker I don't think I can do a good job with it.

@sameersbn
Copy link
Owner

@AdrianRibao your idea of having lightweight containers is valid. But one very important thing here is that we should not break things for existing users. Configuring the image to use sqlite by default will break the image for users who are currently using the builtin mysql server. Also not having a server running on port 80 will have the same effect. Having a builtin nginx server will serve a good purpose here. If you think having nginx is redundant that we can add a configuration option to disable use of nginx server.

@AdrianRibao
Copy link
Author

It's true that it will break things.

About the port 80, I think it's easy to set up unicorn to run on that port, and configure it using an environment variable.

With the mysql database I see more difficulties. It's true that it will break backwards compatibility, and it's a pity because I really like light containers.

If you like the idea of having sqlite as a default database, it's possible to ask users to run a mysql docker container and configure the volumes to use the same as this image had before: https://index.docker.io/u/orchardup/mysql/

It might be complicated, so I understand your point of view.

In my case, I'd would use the light container, because I'm using PostgreSQL as a database, and I don't like the idea of a container running an unnecessary mysql daemon, because it takes resources that are not going to be used.

As I told you before, you can use the parts of code you think are useful and dismiss the others.

One question, why do you compile ruby instead of using the version from ubuntu? was it too old?

@sameersbn
Copy link
Owner

@AdrianRibao Firstly, one issue i see with the sqlite database is the data persistence. I think in the current form the data will be lost if a running container is stopped / deleted and started again. You would need to store the sqlite database on a mounted volume to avoid this.

Secondly, the mysql server is not started if it not going to be used.
The image was first created using instructions from the redmine.org install document and hence the ruby sources are compiled. I am supposed to remove the steps to compile from source and instead install it using apt.

@AdrianRibao
Copy link
Author

Just so you know, I've merged all the changes I made in the master branch of: https://github.com/AdrianRibao/docker-redmine

It includes a simplified Dockerfile with this changes:

  • Support for PostgreSQL
  • Using unicorn
  • Not using apache
  • Not internal MySQL anymore
  • sqlite default db, can be mounted in the host with: -v /var/dockervolumes/redmine/sqlite:/var/redmine/sqlite
  • ruby is not compiled but installed from packages.
  • The default port is again 80

I don't intend to publish the image in index.docker but I'm using it in my own private registry.

If you find helpful some of the changes I made, feel free to use it.

@sameersbn
Copy link
Owner

@AdrianRibao Noted. I am thinking of using unicorn with nginx proxy, its not my immediate plan though. I will try to incorporate your postgresql and sqlite support changes but i may have to create new commits.

@sameersbn
Copy link
Owner

@AdrianRibao In one of my images I had apache removed and was only running the unicorn worker in the container and I quickly realized that unicorn would server the static assets in the public folder. This does not appear to be a good thing because we are making our precious unicorn workers deal with petty file download requests instead of just dealing with the dynamic content.

When apache/nginx is used, we can have the web server to deal with these types of requests while forwarding requests for dynamic content to the unicorn worker processes.

In instance where I found this issue to be at its worse is, I had setup an application to run 2 unicorn workers and was downloading a very large file from a remote location. The download was taking a long time to complete during which unicorn was not ready to handle any other requests since it was too busy dealing with the download.

In summation, I think generally it is not a very good idea to run unicorn without apache/nginx.

P.S. apache+passenger has been removed from the redmine image and is now replaced with nginx+unicorn.

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.

None yet

2 participants