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

Dockerized deployment #28

Merged
merged 2 commits into from
Aug 1, 2017
Merged

Conversation

peterzen
Copy link
Member

Added Docker configuration

@peterzen peterzen closed this Jun 15, 2017
@peterzen peterzen deleted the docker-deployment-setup branch June 15, 2017 15:21
@peterzen peterzen restored the docker-deployment-setup branch June 15, 2017 15:21
@peterzen peterzen reopened this Jun 15, 2017
Dockerfile Outdated
COPY . $APPDIR

# install & configure NodeJS
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way we can avoid this curl to a remote script? We typically prefer to avoid these types of calls.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't perfect, but what I normally do (from a setup script of mine) is:

   # nodejs
    su $USER -c "git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`"
    su $USER -c ". ~/.nvm/nvm.sh && nvm install v6.9.5 && npm install -g npm"
    su $USER -c ""
    su $USER -c "echo '. \$HOME/.nvm/nvm.sh' >> ~/.bashrc"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore the su $USER stuff, that is specific to what I was doing of course.

@jcvernaleo
Copy link
Member

What happened with this PR? @peterzen did you plan on addressing the comment or is this obsolete?

@peterzen
Copy link
Member Author

I wasn't sure if this was being used or not – I've now fixed these items and tested the setup. Can you give it a spin also?

@jcvernaleo
Copy link
Member

Building it fails for me:

Now using node v0.10.40 (npm v1.4.28)
npm WARN package.json batch@0.5.0 No repository field.
npm WARN package.json callsite@1.0.0 No repository field.
npm WARN package.json bytes@0.2.1 No repository field.
npm WARN package.json cookie-signature@1.0.1 No repository field.
npm WARN package.json dateformat@1.0.2-1.2.3 No repository field.
npm WARN package.json emitter@1.0.1 No repository field.
npm WARN package.json eyes@0.1.8 No repository field.
npm WARN package.json faye-websocket@0.4.4 'repositories' (plural) Not supported. Please pick one as the 'repository' field
npm WARN package.json growl@1.7.0 No repository field.
npm WARN package.json has-binary-data@0.1.1 No repository field.
npm WARN package.json indexof@0.0.1 No repository field.
npm WARN package.json object-component@0.0.3 No repository field.
npm WARN package.json parsejson@0.0.1 No repository field.
npm WARN package.json parseqs@0.0.2 No repository field.
npm WARN package.json pause@0.0.1 No repository field.
npm WARN package.json parseuri@0.0.2 No repository field.
npm WARN package.json range-parser@0.0.4 No repository field.
npm WARN package.json socket.io-adapter@0.2.0 No repository field.
npm WARN package.json string_decoder@0.10.31 string_decoder is also the name of a node core module.
npm WARN package.json uid2@0.0.3 No repository field.
npm WARN package.json util@0.10.3 util is also the name of a node core module.
npm WARN excluding symbolic link examples/PayPro/bitcore.js -> ../../browser/bundle.js
npm ERR! Error: EACCES, unlink '/home/insight/insight/node_modules/bufferput'
npm ERR!  { [Error: EACCES, unlink '/home/insight/insight/node_modules/bufferput']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/home/insight/insight/node_modules/bufferput' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 4.4.0-83-generic
npm ERR! command "/home/insight/.nvm/v0.10.40/bin/node" "/home/insight/.nvm/v0.10.40/bin/npm" "install"
npm ERR! cwd /home/insight/insight
npm ERR! node -v v0.10.40
npm ERR! npm -v 1.4.28
npm ERR! path /home/insight/insight/node_modules/bufferput
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/home/insight/insight/node_modules/bufferput'
npm ERR! error rolling back Error: EACCES, unlink '/home/insight/insight/node_modules/bufferput'
npm ERR! error rolling back  { [Error: EACCES, unlink '/home/insight/insight/node_modules/bufferput']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/home/insight/insight/node_modules/bufferput' }
npm ERR! not ok code 0
The command '/bin/sh -c git clone -q https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout -q `git describe --abbrev=0 --tags` &&     . $NVM_DIR/nvm.sh &&     nvm install $NODE_VERSION &&     nvm use $NODE_VERSION &&     cd $APPDIR &&     npm install' returned a non-zero code: 3

@jcvernaleo
Copy link
Member

I'll also ask again as I have on the other docker ones. If this meant for dev or production. If it is for production, I would prefer it checkout code based on a git hash rather than use COPY and live in the dcrdocker repo. If it is mainly for dev then I agree this is the better way to go.

@peterzen
Copy link
Member Author

Hmm, weird. What command line do you use to launch the build?

I meant this to be used for development originally.

@jcvernaleo
Copy link
Member

jcv@triforce ~ $ DOCKER_IMAGE_TAG=insight-api
jcv@triforce ~ $ docker build -t $DOCKER_IMAGE_TAG .

@peterzen
Copy link
Member Author

Did you run npm install beforehand?

@jcvernaleo
Copy link
Member

jcvernaleo commented Jul 25, 2017

I just tried again, made sure I was using the right version of node, did rm -r node_modules followed by npm install then the docker commands and it still failed the same way.

@peterzen
Copy link
Member Author

peterzen commented Jul 25, 2017

I can't reproduce it on Docker version 17.06.0-ce, dockerd running on localhost. Is your dockerd running locally or on a remote host? Could you try with a clean cache, i.e. DOCKER_IMAGE_TAG=insight-api docker build --force-rm --no-cache -t $DOCKER_IMAGE_TAG .

@peterzen
Copy link
Member Author

Oh it's node_modules/ being copied into the image by COPY . $APPDIR - it needed to be added to .dockerignore, it's fixed now. (No need to run npm install before the docker build ...)

@jcvernaleo
Copy link
Member

That fixed it for me.

Copy link
Member

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems all good to me. @alexlyp should confirm that his request got done then good to go.

@peterzen
Copy link
Member Author

Thanks for your comments @jcvernaleo

@jcvernaleo jcvernaleo merged commit 08d3dda into decred:master Aug 1, 2017
@peterzen peterzen deleted the docker-deployment-setup branch January 26, 2018 04:38
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

Successfully merging this pull request may close these issues.

3 participants