stackvana / hook.io

Open-Source Microservice Hosting Platform
https://hook.io
Other
1.27k stars 119 forks source link

Make a dockerfile to setup hook.io environment #181

Closed siuying closed 8 years ago

siuying commented 8 years ago

The aim is finish the Dockerfile and docker-compose setup and make it one command deployable. It is not yet finished.

Marak commented 8 years ago

Seems like a good start.

Once you are able to get the Docker image going from zero to started, let me know and we can try to merge these changes.

siuying commented 8 years ago

Added a setup image in docker-compose to run the setup script ... now basic server can be started:

docker-compose run setup
docker-compose up

But they throw a lot of error like this:

worker_1 | (node) warning: possible EventEmitter memory leak detected. 21 listeners added. Use emitter.setMaxListeners() to increase limit.
worker_1 | Trace
worker_1 |     at EventEmitter.growListenerTree (/src/node_modules/resource/vendor/eventemitter2.js:206:23)
worker_1 |     at EventEmitter.on (/src/node_modules/resource/vendor/eventemitter2.js:366:24)
worker_1 |     at EventEmitter.addMethod [as _addMethod] (/src/node_modules/resource/lib/method.js:248:5)
worker_1 |     at EventEmitter.r.method (/src/node_modules/resource/lib/define.js:89:21)
worker_1 |     at module.exports (/src/node_modules/resource/lib/datasource/all.js:5:5)
worker_1 |     at Object.persist (/src/node_modules/resource/lib/datasource.js:36:3)
worker_1 |     at EventEmitter.addProperty [as _addProperty] (/src/node_modules/resource/lib/property.js:18:23)
worker_1 |     at EventEmitter.r.property (/src/node_modules/resource/lib/define.js:70:14)
worker_1 |     at Object.<anonymous> (/src/lib/resources/hook/index.js:129:6)
worker_1 |     at Module._compile (module.js:460:26)

had no idea what they mean.

Marak commented 8 years ago

@siuying -

Those are warning and can be ignored.

Did you try accessing the http services after starting?

Marak commented 8 years ago

@siuying

I tried running docker-compose run setup, and got the following error:

Any ideas?

Building setup...
Step 0 : FROM node:0.12.7-wheezy
 ---> 30f383483852
Step 1 : RUN apt-get -y update && apt-get -y upgrade
 ---> Using cache
 ---> 787e97be4b7f
Step 2 : RUN apt-get -y install build-essential binutils debootstrap
 ---> Using cache
 ---> 144c4bf2feb7
Step 3 : RUN cd /tmp; git clone https://github.com/tj/mon; cd mon; make install
 ---> Using cache
 ---> c74d0ba912f4
Step 4 : COPY . /src
 ---> Using cache
 ---> 8339b5f2ab5f
Step 5 : RUN cd /src && npm install
 ---> Running in 8d6cb0ba3943
npm WARN package.json hook.io@1.0.0 No repository field.
npm WARN package.json hook.io@1.0.0 license should be a valid SPDX license expression

> iconv@2.1.11 install /src/node_modules/iconv
> node-gyp rebuild

make: Entering directory `/src/node_modules/iconv/build'
  CC(target) Release/obj.target/libiconv/deps/libiconv/lib/iconv.o
  AR(target) Release/obj.target/iconv.a
  COPY Release/iconv.a
  CXX(target) Release/obj.target/iconv/src/binding.o
  SOLINK_MODULE(target) Release/obj.target/iconv.node
  COPY Release/iconv.node
make: Leaving directory `/src/node_modules/iconv/build'
npm WARN prefer global marked@0.3.5 should be installed with -g

> node-icu-charset-detector@0.1.0 install /src/node_modules/node-icu-charset-detector
> node-gyp rebuild

make: Entering directory `/src/node_modules/node-icu-charset-detector/build'
  CXX(target) Release/obj.target/node-icu-charset-detector/node-icu-charset-detector.o
../node-icu-charset-detector.cpp:7:28: fatal error: unicode/ucsdet.h: No such file or directory
compilation terminated.
make: Leaving directory `/src/node_modules/node-icu-charset-detector/build'
make: *** [Release/obj.target/node-icu-charset-detector/node-icu-charset-detector.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 4.0.9-boot2docker
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /src/node_modules/node-icu-charset-detector
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok 

npm ERR! Linux 4.0.9-boot2docker
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.7
npm ERR! npm  v2.14.1
npm ERR! code ELIFECYCLE
npm ERR! node-icu-charset-detector@0.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-icu-charset-detector@0.1.0 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the node-icu-charset-detector package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-icu-charset-detector
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /src/npm-debug.log
Service 'setup' failed to build: The command '/bin/sh -c cd /src && npm install' returned a non-zero code: 1
Marak commented 8 years ago

Okay. Made a bit of progress.

The build error is related to existing node_modules/ folder and cross-system env issue. npm is to blame for that one. rm -rf node_modules/ before building fixes that issue.

Almost got it working now but last command is hanging....going to double check a few things.

Starting hookio_redis_1...
Starting hookio_couch_1...
Starting hookio_worker_1...
Starting hookio_hookio_1...
Starting hookio_setup_1...
Attaching to 
Marak commented 8 years ago

Updated docker locally and made a few more changes.

Currently stuck at getting the admin user connected and configured for couch.

Marak commented 8 years ago

So I've mostly got the Dockerized version of the app working.

Currently the app will load, users can signup and create hooks, hooks can be run.

What is not working is a lot of the redirects and similar items related to knowing the ip address of the docker-machine. You would think that using link and creating a host would be sufficient, but it's not.

Certain parts of the app need to know the IP of the machine. I can solve this locally by modifying the hosts file on my computer ( not the docker machine ) to point to the ip address docker-machine ip returns, but that somewhat defeats the purpose of making a friendly portable Dockerfile.

I have a solution, but it will require I allow for dynamic configuration of hook.io's config.js file after process start. I can then send a command to the app to update the config.baseUrl variable based on the first entry of the docker hosts file.

awk 'NR==1 {print $1}' /etc/hosts

None of this is ideal, I don't see another way around it.

Marak commented 8 years ago

Docker is mostly working now.

I added a special admin route that must be hit after starting the app in order to update the IP address inside app.

Documentation is in the README.