Skip to content

Commit ee8900f

Browse files
committed
chore: \Add dockerfile and docker-compose
1 parent 41cb5d3 commit ee8900f

9 files changed

+115
-0
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
.circleci
3+
.prettierrc
4+
.eslintignore
5+
.git
6+
couchdb-data

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
node_modules
22
package-lock.json
33
config/*.json
4+
couchdb-data
5+
.idea
6+
yarn.lock

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# docker build -t ohif/dicomweb-server:latest .
2+
# docker run -p 5985:5985 ohif/dicomweb-server:latest
3+
# If you want to use PouchDB in this container, add -p 5984:5984
4+
# docker run -p 5985:5985 -p 5984:5984 -e USE_POUCHDB=true ohif/dicomweb-server:latest
5+
FROM node:13.10.1-slim
6+
7+
# Install prerequisites
8+
RUN apt-get update
9+
RUN apt-get -y install git-core \
10+
supervisor
11+
12+
# Grab Source
13+
RUN mkdir /usr/src/app
14+
WORKDIR /usr/src/app
15+
ADD . /usr/src/app
16+
17+
# Restore deps
18+
RUN npm ci
19+
RUN npm install pouchdb-server
20+
21+
# Override config
22+
COPY ./dockersupport/server-config.js config/development.js
23+
24+
# Copy the scripts to run dicomweb-server and PouchDB
25+
COPY ./dockersupport/dicomweb-server-service.sh /usr/src/dicomweb-server-service.sh
26+
RUN chmod 777 /usr/src/dicomweb-server-service.sh
27+
28+
COPY ./dockersupport/conditionally-start-pouchdb.sh /usr/src/conditionally-start-pouchdb.sh
29+
RUN chmod 777 /usr/src/conditionally-start-pouchdb.sh
30+
31+
ENV USE_POUCHDB=false
32+
33+
# Setup Supervisord
34+
COPY ./dockersupport/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
35+
36+
EXPOSE 5984 5985
37+
CMD ["supervisord", "-n"]

docker-compose.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# docker-compose up
2+
# curl -X PUT http://127.0.0.1:5984/_users
3+
# curl -X PUT http://127.0.0.1:5984/_replicator
4+
# curl -X PUT http://127.0.0.1:5984/_global_changes
5+
# curl -X PUT http://127.0.0.1:5984/chronicle
6+
# http://localhost:5984/_utils/
7+
version: '3.8'
8+
9+
services:
10+
dicomweb:
11+
build:
12+
context: .
13+
dockerfile: Dockerfile
14+
image: ohif/dicomweb-server:latest
15+
hostname: dicomweb-server
16+
environment:
17+
- PORT=5984
18+
ports:
19+
- '5985:5985'
20+
depends_on:
21+
- couchdb
22+
restart: unless-stopped
23+
24+
##
25+
# LINK: https://hub.docker.com/_/couchdb
26+
##
27+
couchdb:
28+
image: couchdb:2.3.1
29+
hostname: couchdb
30+
volumes:
31+
- ./couchdb-data:/opt/couchdb/data
32+
ports:
33+
- '5984:5984'
34+
restart: unless-stopped
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
if [ $USE_POUCHDB = "true" ]
4+
then
5+
echo "USE_POUCHDB is true, starting PouchDB service"
6+
/usr/src/app/node_modules/pouchdb-server/bin/pouchdb-server --in-memory --host 0.0.0.0
7+
else
8+
exit 0
9+
fi
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
cd /usr/src/app
3+
npm start

dockersupport/server-config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
env: process.env.NODE_ENV,
3+
dbServer: process.env.USE_POUCHDB === 'true' ? 'http://0.0.0.0' : 'http://couchdb',
4+
db: 'chronicle',
5+
dbPort: process.env.PORT || 5984,
6+
auth: 'none',
7+
logger: true,
8+
};

dockersupport/supervisord.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:pouchdb]
5+
command=bash /usr/src/conditionally-start-pouchdb.sh
6+
stdout_logfile=/var/log/supervisor/%(program_name)s.log
7+
stderr_logfile=/var/log/supervisor/%(program_name)s.log
8+
autorestart=true
9+
10+
[program:dicomweb-server]
11+
command=bash /usr/src/dicomweb-server-service.sh
12+
stdout_logfile=/var/log/supervisor/%(program_name)s.log
13+
stderr_logfile=/var/log/supervisor/%(program_name)s.log
14+
autorestart=true

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "dicomweb-server",
33
"version": "0.0.0-development",
44
"description": "Lightweight DICOMweb Server with CouchDB",
5+
"repository": "https://github.com/dcmjs-org/dicomweb-server",
56
"main": "server.js",
67
"dependencies": {
78
"atob": "^2.1.2",

0 commit comments

Comments
 (0)