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

Running commands within application #156

Closed
hieronx opened this issue Aug 7, 2013 · 18 comments
Closed

Running commands within application #156

hieronx opened this issue Aug 7, 2013 · 18 comments

Comments

@hieronx
Copy link

hieronx commented Aug 7, 2013

Running commands within applications, like rake db:migrate for Ruby on Rails applications, doesn't seem to be possible.

I tried opening a console like this:

docker run -i -t app/name /bin/bash

And running:

cd app && RAILS_ENV=production rake db:migrate

But then I'm getting the following error:

Could not find rake-10.1.0 in any of the sources
Run `bundle install` to install missing gems.

Am I missing something here? Thanks for any help!

@ivey
Copy link

ivey commented Aug 8, 2013

I wasn't able to find the right way into the bundled gems either, and I didn't have time to dig too much today, so I added:

task "assets:precompile" => "db:migrate"

to Rakefile so it would migrate on every deploy.

@ivey
Copy link

ivey commented Aug 8, 2013

The magic is in /start ... after you connect, copy-paste the first 4 lines:

export HOME=/app
for file in /app/.profile.d/*; do source $file; done
hash -r
cd /app

And you can do whatever you need.

@progrium
Copy link
Contributor

progrium commented Aug 8, 2013

Yes, seems like maybe that should be pulled out into a separate script ...
maybe even create a custom entry point for the image that loads that stuff.
Anyway, it would be fixed in buildstep, not Dokku.

On Thu, Aug 8, 2013 at 8:20 AM, Michael D. Ivey notifications@github.comwrote:

The magic is in /start ... after you connect, copy-paste the first 4
lines:

export HOME=/app
for file in /app/.profile.d/*; do source $file; done
hash -r
cd /app

And you can do whatever you need.


Reply to this email directly or view it on GitHubhttps://github.com//issues/156#issuecomment-22330945
.

Jeff Lindsay
http://progrium.com

@caarlos0
Copy link

I believe that running db:migrate in assets:precompile task will now work, because the DATABASE_URL is not exported yet...

see #165

@asm89 asm89 mentioned this issue Aug 16, 2013
@asm89
Copy link
Contributor

asm89 commented Aug 18, 2013

ping @offerijns @ivey @bradleyg Can you guys give #180 a try? You need to update your buildstep install to the PR mentioned there (pull my branch an run "make build").

@asm89
Copy link
Contributor

asm89 commented Aug 21, 2013

@offerijns @ivey @bradleyg I just merged support for dokku run <app> <cmd>. Can you check it out? :)

@asm89 asm89 closed this as completed Aug 21, 2013
@luxifer
Copy link

luxifer commented Aug 22, 2013

nice one

@abstractcoder
Copy link

currently dokku run <app> <cmd> doesn't seem to do anything. I initially installed dokku a few weeks ago and have updated it twice since then.

I still have to use the docker run -i -t app/name /bin/bash work around.

@plietar
Copy link
Contributor

plietar commented Nov 19, 2013

@abstractcoder Can you try to create a /home/dokku/dokkurc containing

export DOKKU_TRACE=1

And post the full output you get when running dokku run. You'll need to update to the latest version of dokku, as support for tracing was added yesterday (well mostly). Make sure you run make install as upgrading pluginhook is required.

@abstractcoder
Copy link

@plietar Here is the output:

+ case "$1" in
+ pluginhook commands run www rake db:migrate
+ cat
+ case "$1" in
+ case "$1" in
+ cat
+ [[ -z www ]]
+ [[ run == config ]]
+ APP=www
+ IMAGE=app/www
+ [[ run == config:* ]]
+ [[ ! -d /home/dokku/www ]]
+ shift 2
+ docker run -i -t app/www /exec rake db:migrate
+ case "$1" in
+ cat
+ cat

It may actually be working but I'm not getting any output.

@plietar
Copy link
Contributor

plietar commented Nov 19, 2013

What about running docker run -i -t app/www /exec rake db:migrate directly ?
Or run docker run -i -t app/www /bin/bash first, and then rake db:migrate.

@plietar
Copy link
Contributor

plietar commented Nov 19, 2013

Also do other commands implemented in plugins give you an output ?
Try dokku url www for example.

@abstractcoder
Copy link

Running dokku url www gives me output.

Since I no longer have any migrations to run I switched to testing dokku run www rake db:migrate:status, which doesnt output anything (except the trace when the DOKKU_TRACE flag is set), but running docker run -i -t app/www /exec rake db:migrate:status does give me the appropriate output.

@plietar
Copy link
Contributor

plietar commented Nov 19, 2013

What about a simple dokku run www echo "Hello"

@abstractcoder
Copy link

No output when running dokku run www echo "Hello"

@plietar
Copy link
Contributor

plietar commented Nov 20, 2013

I just went back to master, and I can reproduce the problem. I'll have a look at it. Seems like a strange pluginhook/pty related error.
Can you open a dedicated issue ?

@abstractcoder
Copy link

I opened #323

@sangyongjung
Copy link

https://www.digitalocean.com/community/tutorials/how-to-use-the-dokku-one-click-digitalocean-image-to-run-a-ruby-on-rails-app

dokku run app_name rake db:migrate

suddenly worked for me. (I used the work around mentioned above until now.)
Anyone else any luck?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants