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

Crashing container when no bower.json file exists. #8

Open
mtheadley opened this issue Dec 4, 2014 · 19 comments
Open

Crashing container when no bower.json file exists. #8

mtheadley opened this issue Dec 4, 2014 · 19 comments

Comments

@mtheadley
Copy link

I hope I can explain this well enough. I have just recently starting to work with the wonders of dokku via Digital Ocean.

I have 2 projects. Lets call them app and api. The app is what you would expect, it has an Angular front end using bower and npm. Following the instructions, everything works perfect. I can deploy to the DO dokku instance, and everything is happy.

For the api project. It does not use bower (no bower.json file). When I push to the same dokku instance, the migration fails, and the container stops. Doing some inspection, I discovered the last command before the container stops is '/app/.bower'. After tinkering around a bit, I created a bower.json file for the api project and re-deployed. The addition of the bower.json file allowed the api project to deploy successfully.

Have I overlooked something within the steps for setting up this add-in? Would a check for the file in the pre-deploy step help?

Thanks,

//Mark.

@alexbeletsky
Copy link
Owner

hey @mtheadley this is really interesting.

can you please provide more details on that. Create a /home/dokku/dokkurc file containing the following:

export DOKKU_TRACE=1

and attach all logs on failed deploy.

@mtheadley
Copy link
Author

@alexanderbeletsky,

Thanks for the response. I recreated the issue this morning. I have 2 remotes set up (bower and no_bower).

Here are the pastebin links for the output:

No_bower: http://pastebin.com/r9NX6FZ2
Bower: http://pastebin.com/t9dm4Rnj

Docker Container Info after each deploy: http://pastebin.com/rmk19HKa

@alexbeletsky
Copy link
Owner

@mtheadley great info!

I see the reason is here,

remote: ++ docker run -d dokku/no_bower /bin/bash -c /app/.bower
remote: + id=e6909ee6caec222ea67776ab4602ab924b4218eac3d21f5ae375bc150ab6ffb1
remote: + docker attach e6909ee6caec222ea67776ab4602ab924b4218eac3d21f5ae375bc150ab6ffb1
remote: 2014/12/04 08:14:40 You cannot attach to a stopped container, start it first
+ for script in '$(ls -d /var/lib/dokku/plugins/*/commands)'
+ /var/lib/dokku/plugins/nginx-vhosts/commands git-receive-pack ''\''no_bower'\'''
+ case "$1" in

for some strange reason, in case then no_bower used the container is not yet started. That's probably due to 0.3 dokku changes, that I didn't considered while developed this.

Don't know why it's happening though..

@mtheadley
Copy link
Author

@alexanderbeletsky,

If /app/.bower is executed, and there isn't a bower.json file, would that cause an error code? And as a result, cause the container to stop? Once the container stops, the attempt to attach would yield the error.

Could you wrap a check in the pre-deploy step to check for the bower.json file? If it doesn't exist, it wouldn't call the /app/.bower command. Adjusting the echo statements based on the file's existence would help as well. (I can try to do that this evening with a fork/pull request.)

@alexbeletsky
Copy link
Owner

the logic is a bit different: first .bower file is injected into container, on release phase it's executing, if there is bower.json file, it's executing bower install otherwise it supposed to just exit.

to do in the way you describe, would make a bit more complex.. but I'll be happy if you submit PR on that.

@mtheadley
Copy link
Author

I think I understand that within the post-build step. The BOWERSCRIPT performs the check, then the if the file does exist, bower is installed via npm.

Does the right side of the pipe (|) always execute? (my shell skills are rusty)

id=$(echo "$BOWERSCRIPT" | docker run -i -a stdin $IMAGE /bin/bash -c "cat > /app/.bower")

so if the BOWERSCRIPT doesn't install bower, the /app/.bower call is still injected into the container?

@alexbeletsky
Copy link
Owner

$BOWERSCRIPT is just a variable that holds script body. It's piped into /app/.bower file which runs after app build.

@meatballs
Copy link

I have exactly the same problem. Here's the last few lines of my failed deployment on an app which doesn't use bower:

  • echo '-----> Running bower script'
    ++ docker run -d dokku/ /bin/bash -c /app/.bower
  • id=2336658fa3d107f28f45ecff237f5e1a5fdf7d9fdcd71ec6a5f65e89bfd04662
  • docker attach 2336658fa3d107f28f45ecff237f5e1a5fdf7d9fdcd71ec6a5f65e89bfd04662
    2014/12/11 17:16:44 You cannot attach to a stopped container, start it first

@mtheadley
Copy link
Author

Create a bower.json file on the root of your project with this info (change the name if you want):

{
  "name": "myproject"
}

dokku should be happy after that.

@meatballs
Copy link

Tried that, I'm afraid - no effect

@alexbeletsky
Copy link
Owner

Guys, I'll try to diagnose that asap. Got back then I have results.

@alexbeletsky
Copy link
Owner

@mtheadley @meatballs please let me know what exact version of dokku you have?

@mtheadley
Copy link
Author

From /home/dokku/VERSION :: v0.2.3

@erutherford
Copy link

I'm seeing this exact same issue in the latest release, v0.3.12-4-gaf8aa56
-----> Running bower script
++ docker run -d dokku/ericdokku /bin/bash -c /app/.bower

  • id=280f32da763a43f0fccf10fd74fa67dd7cf6794598ad34184b9d75ff662caf6d
  • docker attach 280f32da763a43f0fccf10fd74fa67dd7cf6794598ad34184b9d75ff662caf6d
    time="2015-01-08T03:01:05Z" level="fatal" msg="You cannot attach to a stopped container, start it first"

Containers that use bower build without issue.

@erutherford
Copy link

I figured out a pretty simple fix that seems to work. I'll submit a pull request shortly.

@alexbeletsky
Copy link
Owner

@erutherford good stuff! looking forward to check it out :)

@masaeedu
Copy link

masaeedu commented Mar 5, 2015

@erutherford Could you share what the fix was?

@erutherford
Copy link

Sorry, I should have reported back. I need to revisit this issue, because I have two identical systems, and I can't reproduce it on one of them so my test was bogus. When I figure out a fix, I'll submit a pull request. Sorry for the confusion.

@hboylan
Copy link

hboylan commented Dec 8, 2015

@erutherford or anyone else find a solution for this? I'm still getting this issue with v0.4.5

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

No branches or pull requests

6 participants