Skip to content

Commit

Permalink
Added a version of the server that checks out the repo as well
Browse files Browse the repository at this point in the history
Next step: mounting local drive + reload support
  • Loading branch information
shankari committed Mar 5, 2020
1 parent e9426b9 commit b0ac969
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Dockerfile.dev.server-only
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# python 3
FROM continuumio/miniconda3

MAINTAINER K. Shankari (shankari@eecs.berkeley.edu)

# set working directory
WORKDIR /src

# 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

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

#declare environment variables
ENV DB_HOST=''
ENV WEB_SERVER_HOST=''

ADD clone_and_start_server.sh /clone_and_start_server.sh
RUN chmod u+x /clone_and_start_server.sh

EXPOSE 8080

CMD ["/bin/bash", "/clone_and_start_server.sh"]
46 changes: 46 additions & 0 deletions clone_and_start_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#set phone repo using environment variable
echo "Cloning from repo "${SERVER_REPO}" and branch "$SERVER_BRANCH

mkdir -p /src
cd /src
git clone $SERVER_REPO
cd e-mission-server
git clone https://github.com/driftyco/ionic-package-hooks.git ./package-hooks
git fetch origin $SERVER_BRANCH
git checkout -f $SERVER_BRANCH

conda env update --name emission --file setup/environment36.yml
conda clean -t
conda clean -p

pushd webapp
bower update --allow-root
popd

echo ${DB_HOST}
if [ -z ${DB_HOST} ] ; then
local_host=`hostname -i`
sed "s_localhost_${local_host}_" conf/storage/db.conf.sample > conf/storage/db.conf
else
sed "s_localhost_${DB_HOST}_" conf/storage/db.conf.sample > conf/storage/db.conf
fi
cat conf/storage/db.conf

#set Web Server host using environment variable
echo ${WEB_SERVER_HOST}
if [ -z ${WEB_SERVER_HOST}} ] ; then
local_host=`hostname -i`
sed "s_localhost_${local_host}_" conf/net/api/webserver.conf.sample > conf/net/api/webserver.conf
else
sed "s_localhost_${WEB_SERVER_HOST}_" conf/net/api/webserver.conf.sample > conf/net/api/webserver.conf
fi
cat conf/net/api/webserver.conf

source activate emission

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

# use this as the launch script instead if the webapp is crashing
# note that you need to manually start the server in that case
# tail -f /clone_and_start_server.sh
4 changes: 4 additions & 0 deletions examples/em-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ The server is started on port 8080.
- For other operating systems, you may have to use a different host than
`localhost. For more details, check the instructions on connecting to the
[created container in the main README](../../README.md#connecting-to-the-created-container)

### Development

Use the `docker-compose.dev.yml` file
54 changes: 54 additions & 0 deletions examples/em-server/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: "3"
services:
web-server:
image: emission/e-mission-server.dev.server-only:latest
depends_on:
- db
environment:
- SERVER_REPO=https://github.com/e-mission/e-mission-server.git
- SERVER_BRANCH=master
- DB_HOST=db
- WEB_SERVER_HOST=0.0.0.0
# CHANGEME: enable this for autoreloading
# - CHOKIDAR_USEPOLLING=true
deploy:
replicas: 1
restart_policy:
condition: on-failure
ports:
- "8080:8080"
# volumes:
# specify the host directory where the source code should live
# If this is ~/e-mission-phone-docker, then you can edit the files at
# ~/e-mission-phone-docker/e-mission-phone/www/...
# - ~/e-mission-phone-docker:/src/
# - CHANGEME:/src/
# - /tmp/e-mission-phone-docker:/src/
networks:
- emission
db:
image: mongo:3.4
deploy:
replicas: 1
restart_policy:
condition: on-failure
ports:
#This port binding allows you to access the database server outside the host machine. Remove this is you don't need this
#functionality
- "27017:27017"

#Volumes is the preferred way to persist data generated by a container. In this case we use a volume to persist the contents
#of the data base. Learn more about how to use volumes here: https://docs.docker.com/storage/volumes/
# And learn how to configure volumes in your compose file here: https://docs.docker.com/compose/compose-file/#volume-configuration-reference
volumes:
- mongo-data:/data/db
networks:
- emission

networks:
emission:

volumes:
mongo-data:


0 comments on commit b0ac969

Please sign in to comment.