Skip to content

Commit

Permalink
Merge pull request #76 from AdvancedPhotonSource/docker-dev
Browse files Browse the repository at this point in the history
add docker files, configurations, and doc
  • Loading branch information
dongliu authored Jun 28, 2018
2 parents 9ef5a51 + a4ec8c5 commit 49af2d8
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:8
RUN apt-get update && \
apt-get install -y openssl

# Add Tini, see https://github.com/krallin/tini for why
ENV TINI_VERSION v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]

EXPOSE 3001
COPY . /app
# create the certification file for ssl
WORKDIR /app/docker
RUN openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && \
openssl rsa -passin pass:x -in server.pass.key -out server.key && \
rm server.pass.key && \
openssl req -new -key server.key -out server.csr \
-subj "/C=US/ST=WA/L=Seattle/O=Traveler/OU=Dev/CN=example.com" && \
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
WORKDIR /app
RUN npm install
# RUN bower install
CMD ["node", "app.js"]
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3"
networks:
default:
external:
name: traveler-dev
services:
web:
build: .
volumes:
- ./lib:/app/lib
- ./routes:/app/routes
- ./model:/app/model
- ./views:/app/views
ports:
- "3001:3001"
restart: unless-stopped
environment:
- TRAVELER_CONFIG_REL_PATH=docker

44 changes: 44 additions & 0 deletions docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# use docker to set up traveler development environment

## install docker

See <https://docs.docker.com/install/> for instructions.

## create development network

The traveler application and its dependencies will be running in the same network named `traveler-dev`. Run the following to create the network.

```
docker network create -d bridge --subnet 172.18.1.0/24 traveler-dev
```

## get the dependencies

See <https://github.com/dongliu/traveler-mongo> for mongodb and mongo express.

See <https://github.com/dongliu/traveler-ldap> for open ldap and a php ldap admin web interface.

## build and run the application

The traveler application can be run by running
```
docker-compose up
```

The traveler application can be accessed at <https://localhost:3001>

When you run for the first time, docker will build the image for you. If the application does not start successfully, try
```
docker-compose --verbose up
```
for detailed information. You should also check the logs of mongodb and open ldap service to see if there is an issue with those services. You can ssh into the running container with `docker exec -it traveler-aps_web_1 /bin/bash`, where `traveler-aps_web_1` is the running container name.

Run
```
docker-compose down
```
to stop the appplication.

You can run with `docker-compose up -d` in a detached mode. Then you can run `docker-compose logs -f` to check the application log.


27 changes: 27 additions & 0 deletions docker/ad.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"url": "ldap://ldap-service",
"adminDn": "cn=admin,dc=example,dc=org",
"adminPassword": "admin",
"searchBase": "dc=example,dc=org",
"searchFilter": "(&(objectClass=inetOrgPerson)(uid=_id))",
"nameFilter": "(&(objectClass=inetOrgPerson)(displayName=_name)(company=Engineering))",
"groupSearchBase": "dc=example",
"groupSearchFilter": "(&(objectClass=group)(uid=_id))",
"objAttributes": ["uid", "displayName", "ou", "mail", "homephone"],
"memberAttributes": ["uid", "displayName", "ou", "mail", "homephone", "memberOf"],
"groupAttributes": ["uid","displayName","mail"],
"rawAttributes": ["jpegPhoto"],
"defaultKeys": {
"displayName": "displayName",
"memberOf": "memberOf",
"mail": "mail",
"company": "o",
"thumbnailPhoto": "jpegPhoto",
"uid": "uid",
"telephoneNumber": "homephone"
},

"shareUsers": true,
"shareGroups": false,
"transferOwnership": false
}
3 changes: 3 additions & 0 deletions docker/alias.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"group.new.name" : "goup.old.name"
}
9 changes: 9 additions & 0 deletions docker/api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"api_users" : {
"api_read": "api_read_password",
"api_write": "api_write_password"
},
"app_port" : "3443",
"ssl_key": "server.key",
"ssl_cert": "server.crt"
}
25 changes: 25 additions & 0 deletions docker/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"app_port": "3001",
"ssl_key": "server.key",
"ssl_cert": "server.crt",
"top_bar_urls" : [
{
"text": "Controls",
"url": "https://controls.frib.msu.edu/"
},
{
"text": "Report a problem",
"url": "https://controls.frib.msu.edu/controlshelp/"
}
],
"link_target": "_self",
"deployment_name": "development",
"upload_dir" : "../traveler_uploads/",
"log_dir" : "../logs/",
"cookie_sec": "traveler",
"cookie_life": 28800000,
"upload_size" : 5,
"default_form_public_access" : -1,
"default_traveler_public_access" : 0,
"default_binder_public_access" : 0
}
9 changes: 9 additions & 0 deletions docker/auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "ldap",
"service": "https://localhost:3001",
"login_service": "https://localhost:3001/login",
"default_roles": [
"read_all_forms",
"write_public_travelers"
]
}
10 changes: 10 additions & 0 deletions docker/mongo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"server_address": "mongo",
"server_port": "27017",
"traveler_db": "traveler",
"username": "traveler",
"password": "travelerpassword",
"auth": {
"authdb": "traveler"
}
}
12 changes: 12 additions & 0 deletions docker/service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"device_application": "devices",
"device": {
"url": "https://controlsapp1/conf/rs/v0/component/physical"
},
"legacy_traveler": {
"api": "https://controls.frib.msu.edu/traveler1/api.php",
"travelers": "https://controls.frib.msu.edu/traveler1/api.php?resource=travelers",
"devices": "https://controls.frib.msu.edu/traveler1/api.php?resource=travelers&device=",
"assigned": "https://controls.frib.msu.edu/traveler1/showForm.php?assigned="
}
}
8 changes: 8 additions & 0 deletions docker/ui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"terminology": {
"form": "form",
"traveler": "traveler",
"device": "device",
"travelBtn": "Travel"
}
}

0 comments on commit 49af2d8

Please sign in to comment.