Google-IO-Extended-Grand-Rapids / conference_web

The conference app REST API
5 stars 1 forks source link

maven build of the web app container should not be what stands up the tables in postgres #11

Open mccrackend opened 9 years ago

mccrackend commented 9 years ago

We need to separate the concerns of the maven web app build into a container and the postgres db being setup with the right tables. The web container does not always know the proper IP address of the postgres container until after the containers are linked up. Once they're linked, the web container is handed the proper postgres env var's to connect up reliably. As of the writing of this issue, the DB location is hard coded to an IP address that is somewhat consistent after a fresh vagrant up --no-parallel, but that won't always be the case. The below link suggests these var's are handed off after the containers are linked.

http://blog.nickbelhomme.com/php/moving-from-vagrant-to-docker-in-an-easy-way_447

chenry commented 9 years ago

I am still a bit confused @mccrackend.

When we start the web application, it has to know how to connect to the database. We tell it how to connect to the database through one of the many flavors of the application.properties file. In there, we specify the JDBC URL, and it is hardcoded.

We should be able to use the exact same JDBC URL that the web application is using, for when doing the maven builds. Perhaps there is still something that I am still missing.

mccrackend commented 9 years ago

The location of the database should be passed to the web container via environment variables. It should not be hard coded anywhere. For example, in this PHP application from the article, they do a couple things different that us:

1) They don't connect to a database container until after both containers are built and LINKED (this link is the key) 2) The web app then uses environment variables to get the DB URL and PORT

Specifically see line 7 here: https://github.com/NickBelhomme/DockerImages/blob/master/application/app/magic.php#L7

chenry commented 9 years ago

After a lengthy discussion on this topic, the goal we landed on would be for the web application, as part of it's start up, to run the liquibase refactoring. This can be accomplished through the use of the SpringLiquibase class. For more information:

http://www.liquibase.org/documentation/spring.html

chenry commented 9 years ago

@danmikita @mccrackend how strongly do you feel about this?

danmikita commented 9 years ago

@chenry I would still like to simplify the container situation. I still support using SpringLiquibase....