Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x86/bell/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build . -t treehouses/bell:node-latest
25 changes: 25 additions & 0 deletions x86/bell/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM node:6.11-alpine
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dockerfile should be Dockerfile


LABEL MAINTAINER Yunlu Zhou <zhouyunlu0216@ole.org>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add me and @dogi for the future support


ENV version '0.13.21'

RUN mkdir -p /app/server/src
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do mkdir -p /app/server/src since it will create new layer. Just do the WORKDIR here.


RUN apk add --update openssl && npm install express && \
wget -O BeLL-Apps-${version}.tar.gz \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed ...

https://github.com/open-learning-exchange/BeLL-Apps/archive/${version}.tar.gz && \
tar xvf BeLL-Apps-${version}.tar.gz && \
mv BeLL-Apps-${version}/* /app/server/src/ && \
rm /app/server/src/package.json

WORKDIR /app/server/src

COPY server.js ./
COPY package.json ./
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use original .package.json?


RUN chmod +x ./server.js && npm install

EXPOSE 80

CMD ["npm","start"]
26 changes: 26 additions & 0 deletions x86/bell/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "bell-apps",
"description": "A collection of Apps for the BeLL",
"version": "0.0.1",
"author": "R.J. Steinert <rj@rjsteinert.com>",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "http://github.com/open-learning-exchange/bell-apps.git"
},
"dependencies": {
"couchapp": ">= 0.10.0",
"underscore": ">= 1.5.2",
"nano": "6.0.1",
"commander": "2.5.0",
"request": ">= 2.27.0",
"co": ">= 4.6.0",
"cookie": ">= 0.3.1",
"express": "^4.16.1"

},
"engines": { "node": ">= 6.9.2" }
}
23 changes: 23 additions & 0 deletions x86/bell/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env node

var express = require('express')
var PortJack = express()
var path = require("path");

PortJack.get(/^(.+)$/, function(req, res) {
var options = {
"127.0.0.1": "http://127.0.0.1:2200/apps/_design/bell/MyApp/index.html",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The address should set by dynamically and specified by the environment variable.

"localhost": "http://localhost:2200/apps/_design/bell/MyApp/index.html"
}

if (options.hasOwnProperty(req.hostname)) {
res.setHeader('Location', options[req.hostname])
} else {
res.setHeader('Location', 'http://ole.org')
}

res.statusCode = 302
res.end()
})

PortJack.listen(80)
1 change: 1 addition & 0 deletions x86/db-init/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build . -t treehouses/bell:db-init-latest
44 changes: 44 additions & 0 deletions x86/db-init/couchdb-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Options are -u for username -w for passWord and -p for port number
while getopts "u:w:p:h:" option; do
case $option in
u) COUCHUSER=${OPTARG};;
w) COUCHPASSWORD=${OPTARG};;
p) PORT=${OPTARG};;
h) HOST=${OPTARG};;
esac
done

if [ -z "$HOST" ]
then
HOST=127.0.0.1
fi

# Default port for CouchDB accessed from host machine is 2200
PORT=${PORT:-2200}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use standard port 5984 and not 2200

if [ -z "$COUCHUSER" ]
then
COUCHURL=http://$HOST:$PORT
else
COUCHURL=http://$COUCHUSER:$COUCHPASSWORD@$HOST:$PORT
fi

curl -X PUT $COUCHURL/_users
curl -X PUT $COUCHURL/_replicator
curl -X PUT $COUCHURL/_global_changes

for database in /app/databases/*.js; do
curl -X PUT $COUCHURL/${database:15:-3}
case ${database:15:-3} in
"communities" | "languages" | "configurations" ) ;;
* ) /app/node_modules/.bin/couchapp push $database $COUCHURL/${database:15:-3} ;;
esac
done

## add bare minimal required data to couchdb for launching bell-apps smoothly
for filename in /app/init_docs/languages/*.txt; do
curl -d @$filename -H "Content-Type: application/json" -X POST $COUCHURL/languages;
done
curl -d @app/init_docs/ConfigurationsDoc-Community.txt -H "Content-Type: application/json" -X POST $COUCHURL/configurations
curl -d @app/init_docs/admin.txt -H "Content-Type: application/json" -X POST $COUCHURL/members
13 changes: 13 additions & 0 deletions x86/db-init/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

#WAIT_TIME
while ! curl -X GET couchdb:5984/_all_dbs ; do
sleep 1
done


#CORS SETUP
add-cors-to-couchdb http://couchdb:5984

#MIGRATOR
/root/couchdb-setup.sh -p 5984 -h couchdb
20 changes: 20 additions & 0 deletions x86/db-init/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:6.11-alpine
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dockerfile should be Dockerfile


ENV version '0.13.21'

RUN apk update && \
apk add --no-cache bash curl git jq openssl && \
mkdir bell && wget -O bell/BeLL-Apps-${version}.tar.gz \
https://github.com/open-learning-exchange/BeLL-Apps/archive/0.13.21.tar.gz && \
cd bell && tar xvf BeLL-Apps-${version}.tar.gz && \
mkdir -p /app && mv BeLL-Apps-${version}/* /app && \
chmod +x /app/node_modules/.bin/couchapp && \
#CORS DOWNLOAD
npm install -g add-cors-to-couchdb

COPY docker-entrypoint.sh /root/docker-entrypoint.sh
COPY couchdb-setup.sh /root/couchdb-setup.sh

RUN chmod +x /root/couchdb-setup.sh

CMD sh /root/docker-entrypoint.sh
23 changes: 23 additions & 0 deletions x86/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
couchdb:
expose:
- 5984
image: klaemo/couchdb
ports:
- "2200:5984"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use 5984 not 2200

- "2201:5986"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed with klaemo

db-init:
image: treehouses/bell:db-init-latest
depends_on:
- couchdb
bell:
image: treehouses/bell:node-latest
ports:
- "80:80"
environment:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think all these environments necessary

- HOST_PROTOCOL=http
- DB_HOST=127.0.0.1
- DB_PORT=2200
depends_on:
- couchdb
version: "2"