itead / IoTgo

Open source IoT cloud service
http://iotgo.iteadstudio.com
MIT License
380 stars 221 forks source link

Docker file for IoTgo Docker image #7

Open sanyaade-g2g-repos opened 9 years ago

sanyaade-g2g-repos commented 9 years ago

@humingchun

I am interested in the docke image for IoTgo. Where can I can the docker file used for building the image? I have checked on the github folder and its not there

Hear from you soon!

Many thanks!

God blesses!!!

Best regards, Sanyaade

humingchun commented 9 years ago

Hi @sanyaade-g2g-repos

thank you very much for your interest. I wasn't actually using a dockerfile to build the IoTgo image, I was committing a container into an image instead.

But if you prefer a dockerfile, I will try to write one when I have time. It should come before the end of August.

sanyaade-g2g-repos commented 9 years ago

Hi @humingchun,

Ok! Sorry I actually mean container, not the image [I meant --> IoTgo container dockerfile]. My apology!

Although I am new to docker and learning how to use it. I can help also if you give me a brief of guideline on steps you have taken to create IoTgo container. I will try and follow IoTgo build instructions on the github and see if I could achieve the container and then create the dockerfile for it.

Hear from you soon!

Many thanks!

God blesses!!!

Best regards, Sanyaade

sanyaade-g2g-repos commented 9 years ago

Hi @humingchun,

I made a Dockerfile (attached / see below).

I have tested it on my laptop, everything seems a bit working apart from the IoTgo section that is given some problems. The Dockerfile built the image and run but I was not that clear in how I should set the entry-point and the volume drive.

Also I was unable to copy the init.d/iotgo file directly but then I ssh into the container daemon and I did it but it is not committing the changes if I exit and shell back into the container. Please help!

If you can give a little guide on step needed to build it then I can create the Dockerfile properly. Many thanks!

Hear from you soon!

God blesses!!!

Best regards, Sanyaade

#####==============================================================#######
#Experimental IoTgo Docker build file

# Pull base image.
FROM ubuntu:14.04

#### ========================================================================== #######
# Packaged dependencies
RUN \
    apt-get update && \ 
    apt-get install -y build-essential curl git wget

#### ========================================================================== #######
# Install Python.
RUN \
  apt-get update && \
  apt-get install -y python python-dev python-pip python-virtualenv && \
  rm -rf /var/lib/apt/lists/*

# Define working directory.
WORKDIR /data

# Define default command.
CMD ["bash"]

#### =========================================================================== #######
# Install MongoDB.
RUN \
  apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 && \
  echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' > /etc/apt/sources.list.d/mongodb.list && \
  apt-get update && \
  apt-get install -y mongodb-org && \
  rm -rf /var/lib/apt/lists/*

# Define mountable directories.
VOLUME ["/data/db"]

# Define working directory.
WORKDIR /data

# Define default command.
CMD ["mongod"]

# Expose ports.
#   - 27017: process
#   - 28017: http
EXPOSE 27017
EXPOSE 28017

#### =========================================================================== #######
# Install Node.js
RUN \
  cd /tmp && \
  wget http://nodejs.org/dist/node-latest.tar.gz && \
  tar xvzf node-latest.tar.gz && \
  rm -f node-latest.tar.gz && \
  cd node-v* && \
  ./configure && \
  CXX="g++ -Wno-unused-local-typedefs" make && \
  CXX="g++ -Wno-unused-local-typedefs" make install && \
  cd /tmp && \
  rm -rf /tmp/node-v* && \
  npm install -g npm && \
  printf '\n# Node.js\nexport PATH="node_modules/.bin:$PATH"' >> /root/.bashrc

# Define working directory.
WORKDIR /data

# Define default command.
  CMD ["bash"]
#### =========================================================================== #######
# Next setup Nodejs, Bower and Grunt
#
# Node.js w/ Bower & Grunt Dockerfile
#
# https://github.com/dockerfile/nodejs-bower-grunt
#

# Pull base image.
# FROM dockerfile/nodejs
#### =========================================================================== #######
# Install forever, Bower & Grunt
RUN npm install -g forever bower grunt-cli

# Define working directory.
WORKDIR /data

# Define default command.
CMD ["bash"]

#### =========================================================================== #######
# RUN git clone https://github.com/docker/docker-py.git /docker-py \
#   && cd /docker-py \
#   && git checkout -q $DOCKER_PY_COMMIT
#

#### =========================================================================== #######
# Next Setup IoTgo
RUN git clone https://github.com/itead/IoTgo.git  /opt/IoTgo  \
    && cd /opt/IoTgo  \
    && npm install  \
    && cd public/frontend && bower install --allow-root  \
    && cd ../backend && bower install --allow-root  \
    && cd ../..  \
    && cp config.js.sample config.js

#### =========================================================================== #######
# run -d -p 80:80 --name iotgo --link mongodb:mongodb iotgo node /opt/IoTgo/bin/www
CMD -d -p 80:80 --name iotgo --link mongodb:mongodb iotgo node /opt/IoTgo/bin/www

#### =========================================================================== #######
# RUN cp iotgo  /etc/init.d/iotgo
# Add files.
# docker exec -it elated_hodgkin /bin/bash
# run -v /path/to/host/dir:/path/to/container/dir
# RUN -v /var/www/html/iotgo/iotgo:/etc/init.d/iotgo  \
#   && chmod 755 /etc/init.d/iotgo  \
#   && update-rc.d iotgo defaults

CMD -v /var/www/html/iotgo:/mnt  \
    cp /mnt/iotgo /etc/init.d \
    && chmod 755 /etc/init.d/iotgo  \
    && update-rc.d iotgo defaults

#### =========================================================================== #######
# Define mountable directories.
VOLUME ["/data"]

# Define working directory.
WORKDIR /data

# Define default command.
CMD ["bash"]

# Expose ports public/private
EXPOSE 80
EXPOSE 27017
EXPOSE 28017
sanyaade-g2g-repos commented 9 years ago

Hi Everybody,

I need help! A locally installed copy of IoTgo om my Laptop gave the errors below. Please advice

Many thanks!


sanyaade@showcase:/var/www/html/iotgo/localwkdir/IoTgo$ PORT="3000" DEBUG="iotgo" ./bin/www
  iotgo Express server listening on port 3000 +0ms
  iotgo Connect to DB failed! +28ms
  iotgo MongoError: auth fails
    at Object.toError (/var/www/html/iotgo/localwkdir/IoTgo/node_modules/mongoose/node_modules/mongodb/lib/mongodb/utils.js:114:11)
    at /var/www/html/iotgo/localwkdir/IoTgo/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1196:31
    at /var/www/html/iotgo/localwkdir/IoTgo/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1905:9
    at Server.Base._callHandler (/var/www/html/iotgo/localwkdir/IoTgo/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:453:41)
    at /var/www/html/iotgo/localwkdir/IoTgo/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:488:18
    at MongoReply.parseBody (/var/www/html/iotgo/localwkdir/IoTgo/node_modules/mongoose/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
    at null.<anonymous> (/var/www/html/iotgo/localwkdir/IoTgo/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:446:20)
    at emit (events.js:107:17)
    at null.<anonymous> (/var/www/html/iotgo/localwkdir/IoTgo/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:207:13)
    at emit (events.js:110:17)
    at Socket.<anonymous> (/var/www/html/iotgo/localwkdir/IoTgo/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:440:22)
    at Socket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at Socket.Readable.push (_stream_readable.js:126:10)
    at TCP.onread (net.js:538:20) +2ms
widora commented 8 years ago

I meet the same error: iotgo Connect to DB failed! +28ms mongod 3.2.9 node:4.5.0

mohamedmostafaa commented 6 years ago

iotgo Connect to DB failed! +291ms any help