Skip to content

Commit

Permalink
Merge branch 'atton16-dockerize'
Browse files Browse the repository at this point in the history
  • Loading branch information
shankari committed Nov 20, 2018
2 parents fdc39aa + 706be79 commit 8b2bd04
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# python 3
FROM continuumio/miniconda3

MAINTAINER Attawit Kittikrairit

# set working directory
WORKDIR /usr/src/app

# clone from repo
RUN git clone https://github.com/e-mission/e-mission-server.git .

# setup python environment
RUN conda env update --name emission --file setup/environment36.yml
RUN /bin/bash -c "source activate emission; pip install six --upgrade"

# install nodejs, npm and bower
RUN apt-get update
RUN apt-get install -y build-essential
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get -y install nodejs
RUN npm install -g bower
WORKDIR /usr/src/app/webapp
RUN bower update --allow-root
WORKDIR /usr/src/app

# install nano for editing
RUN apt-get -y install nano vim

# cleanup
RUN apt-get -y remove --purge build-essential
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# start the server
ADD docker/start_script.sh /usr/src/app/start_script.sh
RUN chmod u+x /usr/src/app/start_script.sh

EXPOSE 8080

CMD ["/bin/bash", "/usr/src/app/start_script.sh"]
16 changes: 16 additions & 0 deletions conf/net/api/webserver.conf.docker.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"paths" : {
"static_path" : "webapp/www/",
"python_path" : "main",
"log_base_dir" : ".",
"log_file" : "debug.log"
},
"__comment" : "Fill this in for the production server. port will almost certainly be 80 or 443. For iOS, using localhost allows you to test without an internet connection. For AWS and android, make sure that the host 0.0.0.0, localhost does not seem to work",
"server" : {
"host" : "0.0.0.0",
"port" : "8080",
"__comment": "1 hour = 60 min = 60 * 60 sec",
"timeout" : "3600",
"auth": "skip"
}
}
5 changes: 5 additions & 0 deletions conf/storage/db.conf.docker.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"timeseries": {
"url": "e-mission-mongo-1"
}
}
51 changes: 51 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
### Docker Usage Instructions

1. Build docker image

```
docker build -t e-mission-server:latest .
```

2. Create docker network

We will be creating network name `e-mission` which will allows any docker container in the network refer to each other by its `name` instead of IP Address which can be changed over time.

```
docker network create e-mission --driver=bridge
```

3. Run MongoDB

We will be using Official MongoDB Docker image, so no need to build one.

```
docker run -d \
--name=e-mission-mongo-1 \
--net="e-mission" \
--restart=always \
--mount source=e-mission-mongo-1_data,target=/data/db \
--mount source=e-mission-mongo-1_config,target=/data/configdb \
mongo:latest \
--bind_ip_all
```

FOR ADVANCED USER: If you would like to access to MongoDB directly for debugging purpose, you can add the line

```
-p 27017:27017 \
```

and access it like MongoDB is running on your host machine.

4. Run the server

```
docker run -d \
-p 8080:8080 \
--name=e-mission-server-1 \
--net="e-mission" \
--restart=always \
--mount type=bind,source="$(pwd)"/conf/storage/db.conf.docker.sample,target=/usr/src/app/conf/storage/db.conf,readonly \
--mount type=bind,source="$(pwd)"/conf/net/api/webserver.conf.docker.sample,target=/usr/src/app/conf/net/api/webserver.conf,readonly \
e-mission-server:latest
```
7 changes: 7 additions & 0 deletions docker/start_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!bin/bash

# change python environment
source activate emission

# launch the webapp
./e-mission-py.bash emission/net/api/cfc_webapp.py

0 comments on commit 8b2bd04

Please sign in to comment.