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

The node.js plugin doesn't run npm install with this runner #18

Open
jfromaniello opened this issue Sep 4, 2014 · 8 comments
Open

The node.js plugin doesn't run npm install with this runner #18

jfromaniello opened this issue Sep 4, 2014 · 8 comments
Assignees
Milestone

Comments

@jfromaniello
Copy link
Contributor

If I switch from the simple-runner to the docker-runner, the node.js plugin seems to run the npm install from the node.js plugin.

It works if I npm install from the Custom Scripts plugin

@kfatehi
Copy link
Member

kfatehi commented Oct 3, 2014

@knownasilya this is blocked, see Strider-CD/strider-heroku#4 (comment)

@oliversalzburg
Copy link
Member

oliversalzburg commented Jul 13, 2016

I'm looking into this right now. The problem seems to originate from strider-node: https://github.com/Strider-CD/strider-node/blob/master/worker.js#L35

path.join(projectDir, 'package.json') will resolve to a location on the Docker host, not the guest, so Npm install is not called.

There are really a lot of confusing things going on here. It's not that the paths are incorrectly set, strider-docker-runner will still let strider-simple-runner do a lot of work. Which in turn creates directories on the host (like the data and cache directories). This should be a big no-no when considering that we're trying to run stuff in isolation.

@knownasilya, do you have a deeper understanding how all these components are mixed with each other? Saying this is a huge mess is kind of an understatement. The callback hell is very real with this problem.

@oliversalzburg
Copy link
Member

So, digging deeper into the issue. strider-docker-runner makes use of strider-simple-runner, so we will have 2 job queues (strider-simple-runner/lib/jobqueue.js). The job queue is what will invoke our runners, invoke processJob and, thus, cause the incorrect directories in the Docker context.

IMHO, strider-docker-runner must have it's own job queue that is not bound strongly to the processJob method of strider-simple-runner.

@oliversalzburg
Copy link
Member

Okay, so the problem isn't that the paths are wrong. The paths are kinda right, except that the whole plugin is not running in the Docker context. So even if the paths are set to /home/strider/workspace, everything still fails, because it's not executed in the container.

@oliversalzburg
Copy link
Member

This is really impossible to fix IMHO. The code is such a mess I wouldn't even know where to start. The best that could (and probably should) be done, is a big fat error that tells you that no plugins are compatible with the docker runner.

@oliversalzburg
Copy link
Member

Okay, more progress reporting. We're now using an updated docker image: https://github.com/fairmanager/strider-docker-slave

This gives us a newer OS, Node and npm. It also has support for private npm through setting NPM_TOKEN in the environment plugin.

The custom plugin seems mandatory when using Docker. This way you can run npm install in the prepare phase. We've already had a setup for this, so this was easy. IMHO it is best controlled through strider.json:

{
    "runner": {
        "id": "docker"
    },
    "merge_plugins": true,
    "plugins": [
        {
            "id": "custom",
            "enabled": true,
            "showStatus": true,
            "config": {
                "prepare": ".scripts/prepare.sh --<%= ref.branch %>",
                "deploy": ".scripts/deploy.sh --<%= ref.branch %>"
            }
        }
    ]
}

Then you just drop prepare code into .scripts/prepare.sh:

#!/bin/sh
self=`readlink -f "$0"`
basedir=`dirname "$self"`

echo "node -v"; node -v
echo "npm -v"; npm -v

cd ${basedir}
npm install

Now, because we don't run with the Node plugin, no actual testing is done. That's a task for another day :P

@knownasilya
Copy link
Member

Glad you could make some head way on this.

@oliversalzburg
Copy link
Member

This should work now with HEAD of strider-docker-runner and strider-node, without using strider-custom for npm install. Would love some feedback :)

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

4 participants