Closed Bug 936536 Opened 11 years ago Closed 10 years ago

Make webmaker-suite work in a docker instance

Categories

(Webmaker Graveyard :: Webmaker-suite, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: michiel, Assigned: johns)

Details

(Whiteboard: [workweek-devops][workweek][devops])

Attachments

(5 files, 1 obsolete file)

related to https://bugzilla.mozilla.org/show_bug.cgi?id=921508, let's try to see if we can make docker work with this
Working on this!

So far my dockerfile: 

FROM ubuntu

#  MONGODB INSTALL #######################
# Add 10gen official apt source to the sources list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/10gen.list

# Hack for initctl not being available in Ubuntu
RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -s /bin/true /sbin/initctl

RUN apt-get update
RUN apt-get install -y mongodb-10gen

# Create the MongoDB data directory
RUN mkdir -p /data/db

EXPOSE 27017
ENTRYPOINT ["usr/bin/mongod"]
##########################################

# ELASTICSEARCH #############################
# Java 7
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
RUN apt-get update
RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get install oracle-java7-installer -y
###############################################

# ELASTICSEARCH ###########
RUN apt-get install wget -y
RUN wget --no-check-certificate https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.2.tar.gz
RUN tar -xf elasticsearch-0.90.2.tar.gz
RUN rm elasticsearch-0.90.2.tar.gz
EXPOSE 9200
CMD elasticsearch-0.90.2/bin/elasticsearch -f
###########################

# NODEJS ##################
#Add node repository to sources.list and update apt
RUN add-apt-repository ppa:chris-lea/node.js && apt-get update
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y nodejs git python-pip python g++ make software-properties-common
###########################

# WEBMAKER SUITE ###########
RUN mkdir /var/www
RUN cd /var/www && git clone https://github.com/mozilla/webmaker-suite.git
RUN cd /var/www/webmaker-suite && npm install -g bower
RUN cd /var/www/webmaker-suite && npm install -g grunt-cli
RUN cd /var/www/webmaker-suite && npm install -g http-server
RUN cd /var/www/webmaker-suite && /usr/bin/node /var/www/webmaker-suite/install-webmaker.js --username='jdotpz' --s3key='' --s3secret=''
RUN cd /var/www/webmaker-suite && /usr/bin/node /var/www/webmaker-suite/update-webmaker.js
EXPOSE 3000
EXPOSE 3500
EXPOSE 5000
EXPOSE 5050
EXPOSE 7777
EXPOSE 8888
EXPOSE 12416

ADD run.js /var/www/webmaker-suite/run.js

CMD ["/usr/bin/node", "/var/www/webmaker-suite/run.js"]
################################
There is a 42 layer limit, which means I have to put scripts in the directory that Docker will run in a single layer.

ADD addrepos.sh /tmp/addrepos.sh
RUN /bin/bash /tmp/addrepos.sh

ADD install_mongo.sh /tmp/install_mongo.sh
RUN /bin/bash /tmp/install_mongo.sh

EXPOSE 27017
ENTRYPOINT ["usr/bin/mongod"]
##########################################

ADD install_es.sh /tmp/install_es.sh
RUN /bin/bash /tmp/install_es.sh


EXPOSE 9200
CMD elasticsearch-0.90.2/bin/elasticsearch -f
###########################

# WEBMAKER SUITE ###########
RUN mkdir /var/www
RUN cd /var/www && git clone https://github.com/mozilla/webmaker-suite.git
RUN cd /var/www/webmaker-suite && npm install -g bower
RUN cd /var/www/webmaker-suite && npm install -g grunt-cli
RUN cd /var/www/webmaker-suite && npm install -g http-server
RUN cd /var/www/webmaker-suite && /usr/bin/node /var/www/webmaker-suite/install-webmaker.js --username='jdotpz' --s3key='' --s3secret=''
RUN cd /var/www/webmaker-suite && /usr/bin/node /var/www/webmaker-suite/update-webmaker.js
EXPOSE 3000
EXPOSE 3500
EXPOSE 5000
EXPOSE 5050
EXPOSE 7777
EXPOSE 8888
EXPOSE 12416

ADD run.js /var/www/webmaker-suite/run.js

CMD ["/usr/bin/node", "/var/www/webmaker-suite/run.js"]
################################

---

I am making an AMI with docker pre-installed on it, and am imagining a script running off Jenkins to spin up instances with the docker image.

I created a new key and security group for docker nodes, it is quite wide open as this will be dev envs.
Attached file Docker webmakersuite build log (obsolete) —
Dockerfile currently:
FROM ubuntu:12.04

# INSTALL DEPENDENCIES, REPOS ###################
ADD addrepos.sh /tmp/addrepos.sh
RUN /bin/bash /tmp/addrepos.sh

# INSTALL MONGO, ELASTICSEARCH ###################
ADD install_mongo.sh /tmp/install_mongo.sh
RUN /bin/bash /tmp/install_mongo.sh
EXPOSE 27017
ENTRYPOINT ["usr/bin/mongod"]
ADD install_es.sh /tmp/install_es.sh
RUN /bin/bash /tmp/install_es.sh
EXPOSE 9200
CMD elasticsearch-0.90.2/bin/elasticsearch -f

# WEBMAKER SUITE ##############################
RUN mkdir /var/www
RUN cd /var/www && git clone https://github.com/mozilla/webmaker-suite.git
RUN cd /var/www/webmaker-suite && npm install -g bower
RUN cd /var/www/webmaker-suite && npm install -g grunt-cli
RUN cd /var/www/webmaker-suite && npm install -g http-server
RUN cd /var/www/webmaker-suite && /usr/bin/node /var/www/webmaker-suite/install-webmaker.js --username='jdotpz' --s3key='' --s3secret=''
EXPOSE 3000
EXPOSE 3500
EXPOSE 5000
EXPOSE 5050
EXPOSE 7777
EXPOSE 8888
EXPOSE 12416

CMD /usr/bin/node /var/www/webmaker-suite/run.js
My newest dockerfile:

from ubuntu:12.04

ENV DEBIAN_FRONTEND noninteractive
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/share/elasticsearch/bin

RUN echo "deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise main" >> /etc/apt/sources.list
RUN echo "deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise main" >> /etc/apt/sources.list
RUN echo "deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates main" >> /etc/apt/sources.list
RUN echo "deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates main" >> /etc/apt/sources.list
RUN echo "deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN echo "deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv C7917B12
RUN echo 'deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu precise main' | tee /etc/apt/sources.list.d/chrislea.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/10gen.list
RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -s /bin/true /sbin/initctl
RUN mkdir -p /data/db
RUN apt-get update
RUN apt-get install -y g++ software-properties-common make python python-pip nodejs git curl wget mongodb-10gen openjdk-7-jre-headless g++ wget software-properties-common make

RUN useradd webmaker -d / 
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.5.deb
dpkg -i elasticsearch-0.90.5.deb
RUN git clone https://github.com/mozilla/webmaker-suite.git && chown -R webmaker /webmaker-suite
RUN cd /webmaker-suite && npm install -g bower grunt-cli http-server
RUN cd /webmaker-suite && /usr/bin/node /webmaker-suite/install-webmaker.js --username=jdotpz --s3key=lol --s3secret=keyboardcat

EXPOSE 27017
EXPOSE 9200
EXPOSE 3000
EXPOSE 3500
EXPOSE 5000
EXPOSE 5050
EXPOSE 7777
EXPOSE 8888
EXPOSE 12416

USER webmaker
CMD service elasticsearch restart
CMD ["usr/bin/mongod", "--smallfiles"]
CMD cd /webmaker-suite && node run
I'm having problems shown here:

=======================================
Starting all apps in the Webmaker suite
=======================================
[elasticsearch] ERROR { '0': { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' } }
[elasticsearch] execvp(): No such file or directory
elasticsearch process exited with code -1


Pomax tells me it is ES not being there, so that is the next thing I'm trying to tackle
My hopes of running this all out of one container have been dashed by the simple fact that only one CMD can exist per thing you want to run.

I'm working this into vagrant as well to vary up my experience with how this lands, and figure out how someone would dev against it.
Current Dockerfile for suite, now being run as webmaker to allow for bower to install correctly:

from ubuntu:12.04

ENV DEBIAN_FRONTEND noninteractive
RUN echo "deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise main" >> /etc/apt/sources.list
RUN echo "deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise main" >> /etc/apt/sources.list
RUN echo "deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates main" >> /etc/apt/sources.list
RUN echo "deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates main" >> /etc/apt/sources.list
RUN echo "deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN echo "deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv C7917B12
RUN echo 'deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu precise main' | tee /etc/apt/sources.list.d/chrislea.list

RUN apt-get update
RUN apt-get install -y g++ software-properties-common make python python-pip nodejs git curl wget g++ wget make

RUN adduser webmaker --system --disabled-password --home /webmaker-suite
RUN cd /webmaker-suite && git clone https://github.com/mozilla/webmaker-suite.git && chown -R webmaker /webmaker-suite/webmaker-suite
RUN cd /webmaker-suite/webmaker-suite && su webmaker -C npm install -g bower grunt-cli http-server
RUN cd /webmaker-suite/webmaker-suite && && su webmaker -C /usr/bin/node //webmaker-suite/webmaker-suite/install-webmaker.js --username=jdotpz --s3key=lol --s3secret=keyboardcat

EXPOSE 3000
EXPOSE 3500
EXPOSE 5000
EXPOSE 5050
EXPOSE 7777
EXPOSE 8888
EXPOSE 12416
WORKDIR /webmaker-suite/webmaker-suite
USER webmaker
CMD node run
Current ES Dockerfile:

FROM ubuntu:12.04
MAINTAINER jp "john.p.schneider@gmail.com"
 
# Java 7
ENV DEBIAN_FRONTEND noninteractive
RUN echo "deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise main" >> /etc/apt/sources.list
RUN echo "deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise main" >> /etc/apt/sources.list
RUN echo "deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates main" >> /etc/apt/sources.list
RUN echo "deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates main" >> /etc/apt/sources.list
RUN echo "deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN echo "deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
 
# elasticsearch
RUN apt-get install wget -y
RUN wget --no-check-certificate https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.2.tar.gz
RUN tar -xf elasticsearch-0.90.2.tar.gz
RUN rm elasticsearch-0.90.2.tar.gz
 
EXPOSE :9200
 
CMD elasticsearch-0.90.2/bin/elasticsearch -f
I'm working on making this run as the right user.  Bower does not like being root for its install, unless the --allow-root option is given.

Meanwhile, other packages have problems if we run the install-webmaker.js as unprivileged user webmaker.
https://pastebin.mozilla.org/3655472
OK, I've got it built, and have some scripts to start it.

I'm first including the three Dockerfile's I'm using (for webmaker-suite, mongo, and elasticsearch).
Attachment #829488 - Attachment is obsolete: true
Attached file Dockerfile-mongo
Attached file Vagrantfile
Vagrant file, rough draft needs work.
Next, the logs from the webmaker-suite build.  Has a few errors we need to review.
Attached file dockerbuild.out
This was the build log for docker installing webmaker suite using the above Dockerfile.  There are a few errors in there.
Attachment #8337057 - Flags: review?(pomax)
OK, getting closer!

vagrant@precise64:~$ sudo docker run -p 0.0.0.0:3000:3000 -p 0.0.0.0:3500:3500 -p 0.0.0.0:5000:5000 -p 0.0.0.0:5050:5050 -p 0.0.0.0:7777:7777 -p 0.0.0.0:8888:8888 -p 0.0.0.0:12416:12416 webmaker/suite &
[1] 13017
vagrant@precise64:~$ 
=======================================
Starting all apps in the Webmaker suite
=======================================
[elasticsearch] ERROR { '0': { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' } }
[elasticsearch] execvp(): No such file or directory
elasticsearch process exited with code -1

That said, I do see 9200 available on the host.
tcp6       0      0 :::9200                 :::*                    LISTEN     

vagrant@precise64:~$ sudo docker ps
CONTAINER ID        IMAGE                           COMMAND                CREATED             STATUS              PORTS                      NAMES
c2e0ea106883        webmaker/mongo:latest           usr/bin/mongod --sma   2 minutes ago       Up 2 minutes        0.0.0.0:27017->27017/tcp   lavender_whale      
f5e9513692a0        webmaker/elasticsearch:latest   /bin/sh -c /usr/shar   2 minutes ago       Up 2 minutes        0.0.0.0:9200->9200/tcp     crimson_spider
I'm able to open those ports by issuing these commands to bring up docker containers:

sudo docker run -p 127.0.0.1:9200:9200 webmaker/elasticsearch &
sudo docker run -p 127.0.0.1:27017:27017 -name mongoserver webmaker/mongo &
sudo docker run -p 127.0.0.1:3000:3000 -p 127.0.0.1:3500:3500 -p 127.0.0.1:5000:5000 -p 127.0.0.1:5050:5050 -p 127.0.0.1:7777:7777 -p 127.0.0.1:8888:8888 -p 127.0.0.1:12416:12416 webmaker/suite &

I may have to link these rather than expose ports on the main host, we'll see.
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:9200          0.0.0.0:*               LISTEN  

CONTAINER ID        IMAGE                           COMMAND                CREATED             STATUS              PORTS                        NAMES
5535923538aa        webmaker/elasticsearch:latest   /bin/sh -c /usr/shar   23 minutes ago      Up 23 minutes       127.0.0.1:9200->9200/tcp     pink_frog           
4fdea67ec860        webmaker/mongo:latest           usr/bin/mongod --sma   38 minutes ago      Up 38 minutes       127.0.0.1:27017->27017/tcp   mongoserver
OK, I'm trying to go back to a single container so as to easily expose 27017 and 9200 so webmaker suite can see it.

We added --allow-root here to fix the bower issues, but we're still seeing them: https://github.com/mozilla/webmaker-suite/blob/master/install-webmaker.js#L257

> bower install
bower ESUDO         Cannot be run with sudo

Additional error details:
Since bower is a user command, there is no need to execute it with superuser permissions.
If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.

http://www.joyent.com/blog/installing-node-and-npm
https://gist.github.com/isaacs/579814

You can however run a command with sudo using --allow-root option
> bower update
bower ESUDO         Cannot be run with sudo

Additional error details:
Since bower is a user command, there is no need to execute it with superuser permissions.
If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.

http://www.joyent.com/blog/installing-node-and-npm
https://gist.github.com/isaacs/579814

You can however run a command with sudo using --allow-root option


We're dealing with a few errors in the build still, but not sure they are valid:

npm ERR! Error: version not found: 0.1.18 : webmaker-loginapi/0.1.18
npm ERR!     at RegClient.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:272:14)
npm ERR!     at Request.self.callback (/usr/lib/node_modules/npm/node_modules/request/request.js:129:22)
npm ERR!     at Request.EventEmitter.emit (events.js:98:17)
npm ERR!     at Request.<anonymous> (/usr/lib/node_modules/npm/node_modules/request/request.js:873:14)
npm ERR!     at Request.EventEmitter.emit (events.js:117:20)
npm ERR!     at IncomingMessage.<anonymous> (/usr/lib/node_modules/npm/node_modules/request/request.js:824:12)
npm ERR!     at IncomingMessage.EventEmitter.emit (events.js:117:20)
npm ERR!     at _stream_readable.js:920:16
npm ERR!     at process._tickCallback (node.js:415:13)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 3.2.0-23-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "update"
npm ERR! cwd /webmaker-suite/goggles.webmaker.org
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14

Another one similar I see with makeapi.
Attachment #8337057 - Flags: review?(pomax)
Well, docker has proved difficult to adapt to webmaker-suite.  

For the moment, I have created a first draft vagrant box image with webmaker-suite, mongo, and elasticsearch installed.  I have added a readme and Vagrantfile in the webmaker-suite repo, I have this pull request up for it to the suite repo: https://github.com/mozilla/webmaker-suite/pull/14/files

Next steps will be to add to the MOTD, cleanup history, perhaps add in prompts for things like git username, auto-updates....what else?
I have merged my Vagrantfile to master, and added a readme:
https://github.com/mozilla/webmaker-suite/tree/master/vagrant

This is not the original Docker instance this ticket called for but it is an easily deployable way to get up and running.

Pomax, I'd love some feedback on this.
Flags: needinfo?(pomax)
Added this to the MOTD for the vagrant instance:

###########################################################
## Mozilla Foundation webmaker-suite vagrant box
##
##   Github: https://github.com/mozilla/webmaker-suite
##   Support: webmaker-dev@mozillafoundation.org or devops@mozillafoundation.org
##
##   INSTRUCTIONS FOR USE 
##   - Upon launch, run the following command to update
##     webmaker suite to latest versions:
##       cd /home/vagrant/webmaker-suite && node update-webmaker
##
##   - Upon launch, you may wish to add your own github remotes
##     to allow for testing of new branches or commits.  To do
##     so, use the /home/vagrant/webmaker-suite/add-remote.js command
##     by issuing it as follows:
##       cd /home/vagrant/webmaker-suite && node add-remote.js
##
##   - To start the webmaker suite, issue the following command as vagrant user
##       /home/vagrant/webmaker-suite.sh
##     This will start elasticsearch, mongo, and all webmaker suite components
##
##  ACCESSING THROUGH YOUR LOCAL BROWSER
##   http://localhost:3000 - login.webmaker.org
##   http://localhost:3500 - thimble.webmaker.org
##   http://localhost:5000 - makeapi
##   http://localhost:5050 - htmlsanitizer.org
##   http://localhost:7777 - webmaker.org
##   http://localhost:8888 - popcorn.webmaker.org
##   http://localhost:12416 - goggles.webmaker.org
##
#####################################################################
Flags: needinfo?(pomax)
Whiteboard: [workweek-devops][workweek]
Status: NEW → ASSIGNED
Whiteboard: [workweek-devops][workweek] → [workweek-devops][workweek][devops]
We have figured a way to allow for local workstation development on webmaker-suite in a vagrant instance.

The process will be to create a folder, say ~/vagrant/.  Then, git clone webmaker-suite in that directory.  Place the Vagrantfile in the same folder, then vagrant up.

The one question I need to answer is how updating remote or updating webmaker-suite will work.
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
(In reply to JP Schneider :jp from comment #6)
> I'm having problems shown here:
> 
> =======================================
> Starting all apps in the Webmaker suite
> =======================================
> [elasticsearch] ERROR { '0': { [Error: spawn ENOENT] code: 'ENOENT', errno:
> 'ENOENT', syscall: 'spawn' } }
> [elasticsearch] execvp(): No such file or directory
> elasticsearch process exited with code -1
> 

Hello JP Schneider,

I am getting same error on my system (Debian 7). I have installed ES and Mongodb too. Can you help me to solve this error.

Thanks in advance,

Mandeep Simak
HI Mandeep!

Can you tell me if you were using a vagrant instance, or the webmaker suite app itself off of github?  If you were using vagrant, were you using the local version, or the AWS version?

I'm happy to help you get up and running.  I'm actually going to be working on a new build for this app today.
(In reply to JP Schneider :jp from comment #27)
> HI Mandeep!
> 
> Can you tell me if you were using a vagrant instance, or the webmaker suite
> app itself off of github?  If you were using vagrant, were you using the
> local version, or the AWS version?

I'm using webmaker suite cloned from github.

> I'm happy to help you get up and running.  I'm actually going to be working
> on a new build for this app today.

Ok, Thats great.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: