sozialhelden / wheelmap-classic

:wheelchair: Legacy "classic" wheelmap.org (deprecated)
http://www.wheelmap.org
GNU Affero General Public License v3.0
47 stars 16 forks source link

Create a Dockerfile for easier development setup #49

Open ghost opened 8 years ago

ghost commented 8 years ago

I'm creating a Dockerfile over at https://github.com/voltagex/wheelmap/blob/master/Dockerfile, hopefully when this is all set it'll make setting up a development environment for wheelmap much easier.

TODO:

joustava commented 8 years ago

@voltagex what are the errors?

ghost commented 8 years ago

@joustava if I use ONBUILD bundle install it's silent. I'm going to remove ONBUILD completely because it doesn't seem to give me any advantage. After that I get Could not locate Gemfile

joustava commented 8 years ago

have you tried ADD instead of ONBUILD COPY?

ghost commented 8 years ago

Thanks for that tip, the current master looks like it's working. I'll try setting up MySQL in either this container or another one tomorrow.

ghost commented 8 years ago

Making good progress, I need someone else to test this. I now have a docker-compose file for the whole setup that should launch a MySQL database and wheelmap. At the moment I haven't customised the database build so it won't have the right database there, but it should at least connect

ghost commented 8 years ago

I'm stuck. The database rake steps won't work if the database isn't on localhost. This is hardcoded in Rails 3.2.2 and can't be overridden with an environment variable. It looks like it's fixed in Rails 4, sort of.

I could just install MySQL in the same container as the app, but it's much better and easier to use a separate container - this way I can use the official MySQL image.

I'm also waiting on docker/compose#2302 to be resolved so that the database server hostname stays the same between builds.

joustava commented 8 years ago

@voltagex if you help/tell me with how I should test it, I could take a look. I can run it in a vagrant box e.g?

ghost commented 8 years ago

@joustava If you can install docker and docker-compose on a Vagrant box it's as simple as following the instructions in https://github.com/voltagex/wheelmap#docker - just make sure you clone my version of wheelmap until the changes are merged.

The db rake seed command will fail at the moment and I don't have a workaround. If you can generate SQL that does the same thing I will use that in the Docker script.

As of 2pm AEST I've broken my Dockerfile - I'm rebuilding it against Alpine and putting the database in the same image. This brings the first-download size for developers down from 2+GB (!) to ~300mb.

Okay, that got very complicated. I've gone back to my original Dockerfile but the MySQL setup is tricky. I can't use https://github.com/docker-library/mysql/blob/master/5.7/docker-entrypoint.sh in my file as AGPL3 and GPL2 are incompatible.

If you have any issues with the instructions not being clear enough, that's a bug, let me know.

ghost commented 8 years ago

I'm stuck. We can't run rake db:seed against "remote" databases (i.e. in another container) but Docker really isn't set up to run more than one service per container (e.g. mysqld &, bundle exec server)

lennerd commented 8 years ago

@skade @christoph-buente Can you help out here?

Xylakant commented 8 years ago

I can take a stab at this on monday. Need to set up a dev environment anyways. It's possible to run multiple processes in a single container by using a short script that spawns them (foreman, a mini init, ...), but it should also be possible to use a second container for mysql.

Xylakant commented 8 years ago

db:seed should work against a remote database, however, the current way it's laid out in the Dockerfile won't work for two reasons:

ghost commented 8 years ago

Ping @Xylakant

ghost commented 8 years ago

I am reducing my open-source todo list for the moment - this needs another set of eyes but I am still interested

db:seed would not connect to a remote database for me.

Xylakant commented 8 years ago

I'll just grab that if you don't mind

Xylakant commented 8 years ago

It's possible to run run the db:create command on remote machines by overwriting local_database? in active_record. However, there's a bit of a problem since I'm uncertain that docker/docker-compose always assigns the same IP space to the docker interface.

Xylakant commented 8 years ago

we also have some broken migration that tries to create a primary key with a null component.

ghost commented 8 years ago

However, there's a bit of a problem since I'm uncertain that docker/docker-compose always assigns the same IP space to the docker interface.

When you set up entries for different containers in docker-compose.yml, it should create corresponding /etc/hosts entries that you can rely on.

Xylakant commented 8 years ago

Ok, I sort of have this working, but it needs major tweaking.

First of all it makes little sense to use ADD to add the application to the container. That would mean you have to rebuild every time you do a code change. It's probably better to just mount the app directory as a volume.

I'm also not convinced that creating the database on build is the best option since a single failed migration means no container, no way to run rake etc. However, if we don't have a database the container fails to start up.