kekshd / keks

an elearning system with basic answer types yes/no/matrix
http://keks.uni-hd.de
ISC License
10 stars 4 forks source link

Running rails server during during dockerbuild? #129

Open joker234 opened 6 years ago

joker234 commented 6 years ago

Why do you start the rails app during the build. This breaks most deployment flows and needs ugly hacks like docker exec rm /usr/src/app/tmp/pids/server.pid. https://github.com/kekshd/keks/blob/c7e1bb6b05b21426f3a410d56856ffb5374088b9/Dockerfile#L7 https://github.com/kekshd/keks/blob/c7e1bb6b05b21426f3a410d56856ffb5374088b9/start.sh#L7

If you have to start the app please stop it again or take care of the annoying pid file.

joker234 commented 6 years ago

Okay nevermind. I missread the Dockerfile.

joker234 commented 6 years ago

Okay now I found out the main problem. Do you really want to execute these lines on each start of keks? https://github.com/kekshd/keks/blob/c7e1bb6b05b21426f3a410d56856ffb5374088b9/start.sh#L3-L6 On all other deployments we do the migration/precompile stuff. Like it is deployed now, on every restart the assets get precompiled again. Is this intentional?

oqpvc commented 6 years ago

To an extent.

The Dockerfile was designed to need minimal outside interference — mostly accounting for the fact that I have no control over the actual deployment.

Now, precompiling the assets is something that should actually be part of the build process and I'd love to simply put the corresponding line into the Dockerfile. But for reasons beyond me, the precompiling process needs a functioning DB connection — hence is something that has to be done after setting up the container. Now because I have no control over the actual deployment, the startup file seems to be the correct place to put the directive. In theory, it should only add a second or two to the startup process and cause no harm.

Aesthetically, I prefer minimal deployment voodoo and maximal encapsulation, which is how I tend to write my Dockerfiles. Orphan run files probably stem from unplanned shutdowns of Keks in conjunction with the old Rails version not implementing an annoying hack on its own.

Personally, I don't have a strong preference for the Keks startup process either way. Rearrange those commands as you please: Add a delete directive to the startup file, do more magic in the deployment script, whatever floats your boat.