From 83ba192985ee57d87b3e3c59b30ec9f1ba13093c Mon Sep 17 00:00:00 2001 From: Sacheendra Talluri Date: Wed, 25 Jan 2017 14:35:53 +0100 Subject: updates submodules --- opendc-frontend | 2 +- opendc-simulator | 2 +- opendc-web-server | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/opendc-frontend b/opendc-frontend index c96e6ffa..a1ad7ed9 160000 --- a/opendc-frontend +++ b/opendc-frontend @@ -1 +1 @@ -Subproject commit c96e6ffafb62bde1e08987b1fdf3c0786487f6ec +Subproject commit a1ad7ed96a3c67705ff2db610d18f6916d8094bf diff --git a/opendc-simulator b/opendc-simulator index 04d0c8d1..d8d6244c 160000 --- a/opendc-simulator +++ b/opendc-simulator @@ -1 +1 @@ -Subproject commit 04d0c8d157dd4feef7f19f225ad5a41c20303704 +Subproject commit d8d6244c2f06b2079baa44d7413fb79664adfc69 diff --git a/opendc-web-server b/opendc-web-server index 537d9fa8..8a8279ec 160000 --- a/opendc-web-server +++ b/opendc-web-server @@ -1 +1 @@ -Subproject commit 537d9fa8035b81ac52bc2104cc4e80e79b72628d +Subproject commit 8a8279ec685311ceffd2aadb1dc7c76e8637f043 -- cgit v1.2.3 From 8b123384237a40801a621a1df6c094562eee52c1 Mon Sep 17 00:00:00 2001 From: Sacheendra Talluri Date: Thu, 26 Jan 2017 18:41:21 +0100 Subject: Update submodules to be compatible with Docker build --- opendc-frontend | 2 +- opendc-web-server | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opendc-frontend b/opendc-frontend index a1ad7ed9..3ad08353 160000 --- a/opendc-frontend +++ b/opendc-frontend @@ -1 +1 @@ -Subproject commit a1ad7ed96a3c67705ff2db610d18f6916d8094bf +Subproject commit 3ad08353d289720cf8f43e1dba078da43c35e97d diff --git a/opendc-web-server b/opendc-web-server index 8a8279ec..1b942d9e 160000 --- a/opendc-web-server +++ b/opendc-web-server @@ -1 +1 @@ -Subproject commit 8a8279ec685311ceffd2aadb1dc7c76e8637f043 +Subproject commit 1b942d9e9d5b2c08d09fb8f294437ea99a889962 -- cgit v1.2.3 From 01410021a7fe733edab64d7cb4b359685d89cd91 Mon Sep 17 00:00:00 2001 From: Sacheendra Talluri Date: Thu, 26 Jan 2017 18:42:38 +0100 Subject: Add Dockerfile and related build files --- .dockerignore | 0 .gitignore | 1 + Dockerfile | 33 +++++++++++++++++++++++++++++++++ build/configure.sh | 34 ++++++++++++++++++++++++++++++++++ build/frontend_config.json | 3 +++ build/keys.json | 7 +++++++ build/supervisord.conf | 16 ++++++++++++++++ 7 files changed, 94 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100755 build/configure.sh create mode 100644 build/frontend_config.json create mode 100644 build/keys.json create mode 100644 build/supervisord.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..e69de29b diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..496ee2ca --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ad17f041 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM node:7.4 +MAINTAINER Sacheendra Talluri + +# Installing python, yarn, gulp and web-server dependencies +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ + && echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ + && echo "deb http://ftp.debian.org/debian stretch main" >> /etc/apt/sources.list \ + && apt-get update \ + && apt-get -y -t stretch install gcc-6 g++-6 \ + && apt-get install -y python python-pip yarn git sqlite3 sed supervisor \ + && pip install oauth2client eventlet flask-socketio \ + && npm install -g gulp-cli \ + && rm -rf /var/lib/apt/lists/* + +# Copy opendc +COPY ./ /opendc + +# Setting up simulator +RUN mkdir -p /data/database \ + && chmod 555 /opendc/build/configure.sh \ + && cd /opendc/opendc-simulator/Simulator \ + && rm -f ./simulator ./sqlite3.o \ + && make \ + && chmod 555 ./simulator \ + && git config --global url."https://".insteadOf git:// #needed for gulp to work \ + && cd /opendc/opendc-frontend \ + && rm -rf /opendc/opendc-frontend/build \ + && yarn \ + && gulp --config=../build/frontend_config.json + +CMD ["sh", "-c", "cd /opendc && ./build/configure.sh /data/database && /usr/bin/supervisord -c /opendc/build/supervisord.conf"] + +VOLUME ["/data/database"] \ No newline at end of file diff --git a/build/configure.sh b/build/configure.sh new file mode 100755 index 00000000..75a61e7d --- /dev/null +++ b/build/configure.sh @@ -0,0 +1,34 @@ +if [ ! -f "$1/opendc.db" ]; then + sqlite3 "$1/opendc.db" < ./database/schema.sql + sqlite3 "$1/opendc.db" < ./database/test.sql +fi + +if [ -z "$OAUTH_CLIENT_ID" ] +then + echo "OAuth client id not found. Define environment variable OAUTH_CLIENT_ID" + exit 1 +fi + +if [ -z "$OAUTH_CLIENT_SECRET" ] +then + echo "OAuth client secret not found. Define environment variable OAUTH_CLIENT_SECRET" + exit 2 +fi + +if [ -z "$SERVER_URL" ] +then + echo "URL of server not found. Define environment variable SERVER_URL" + exit 2 +fi + +sed -i "s/client-id/$OAUTH_CLIENT_ID/g" ./build/keys.json +sed -i "s/client-secret/$OAUTH_CLIENT_SECRET/g" ./build/keys.json + +# ignore non ASCII characters +LC_CTYPE=C +LANG=C + +find ./opendc-frontend/build -type f -exec sed -i "s/the-google-oauth-client-id/$OAUTH_CLIENT_ID/g" {} \; +find ./opendc-frontend/build -type f -exec sed -i "s,https://opendc.ewi.tudelft.nl:443,$SERVER_URL,g" {} \; +find ./opendc-frontend/build -type f -exec sed -i "s,https://opendc.ewi.tudelft.nl,$SERVER_URL,g" {} \; +find ./opendc-frontend/build -type f -exec sed -i 's,LOCAL_MODE = (document.location.hostname === "localhost"),LOCAL_MODE = false,g' {} \; \ No newline at end of file diff --git a/build/frontend_config.json b/build/frontend_config.json new file mode 100644 index 00000000..bdaede00 --- /dev/null +++ b/build/frontend_config.json @@ -0,0 +1,3 @@ +{ + "GOOGLE_OAUTH_CLIENT_ID": "the-google-oauth-client-id" +} \ No newline at end of file diff --git a/build/keys.json b/build/keys.json new file mode 100644 index 00000000..6af01a9c --- /dev/null +++ b/build/keys.json @@ -0,0 +1,7 @@ +{ + "OAUTH_CLIENT_ID": "client-id", + "OAUTH_CLIENT_SECRET": "client-secret", + "ROOT_DIR": "/opendc", + "FLASK_SECRET": "This is a super duper secret flask key", + "DATABASE_LOCATION": "/data/database/opendc.db" +} \ No newline at end of file diff --git a/build/supervisord.conf b/build/supervisord.conf new file mode 100644 index 00000000..534eda29 --- /dev/null +++ b/build/supervisord.conf @@ -0,0 +1,16 @@ +[supervisord] +nodaemon=true + +[program:web-server] +command=/usr/bin/python2.7 /opendc/opendc-web-server/main.py /opendc/build/keys.json +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:simulator] +command=/bin/sh -c '/opendc/opendc-simulator/Simulator/simulator /data/database/opendc.db' +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 \ No newline at end of file -- cgit v1.2.3 From 04e05052910a58790bdabd4e8d4232e5fb3c6e0a Mon Sep 17 00:00:00 2001 From: Sacheendra Talluri Date: Thu, 26 Jan 2017 18:49:38 +0100 Subject: Add build steps to README --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 89f554e8..a588089e 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,21 @@ The simulator monitors this `queued_experiments` table, and simulates experiment ## Setup -To build and run the full OpenDC stack locally: +The official way to run OpenDC is using Docker. -First, clone this repository and its submodules: +To build and run the full OpenDC stack locally: ```bash +# Clone the repo and its submodules git clone --recursive git@github.com:tudelft-atlarge/opendc.git + +# Build the Docker image +docker build -t="opendc" . + +# Start a container with the image +docker run -d --name opendc -p 8081:8081 -e 'SERVER_URL=http://localhost:8081' -e 'OAUTH_CLIENT_ID=your-google-oauth-client-id' -e 'OAUTH_CLIENT_SECRET=your-google-oauth-secret' opendc + +# Wait a few seconds and open http://localhost:8081 in your browser ``` -Then... [TO DO] + -- cgit v1.2.3 From 9219552f299eef0893043c48b00506a56287058b Mon Sep 17 00:00:00 2001 From: Sacheendra talluri Date: Thu, 26 Jan 2017 18:52:19 +0100 Subject: Add change folder step to README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index a588089e..b9303132 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,9 @@ To build and run the full OpenDC stack locally: # Clone the repo and its submodules git clone --recursive git@github.com:tudelft-atlarge/opendc.git +# Enter the directory +cd opendc/ + # Build the Docker image docker build -t="opendc" . -- cgit v1.2.3 From f0fbaef7cdf8f09fe48b0e1b956feb1840836639 Mon Sep 17 00:00:00 2001 From: Sacheendra Talluri Date: Mon, 6 Feb 2017 12:01:21 +0100 Subject: Remove breaking comment from dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ad17f041..9df8dca5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ RUN mkdir -p /data/database \ && rm -f ./simulator ./sqlite3.o \ && make \ && chmod 555 ./simulator \ - && git config --global url."https://".insteadOf git:// #needed for gulp to work \ + && git config --global url."https://".insteadOf git:// \ && cd /opendc/opendc-frontend \ && rm -rf /opendc/opendc-frontend/build \ && yarn \ -- cgit v1.2.3