Skip to content

chore: Add dockerfile and docker-compose #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
.circleci
.prettierrc
.eslintignore
.git
couchdb-data
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
node_modules
package-lock.json
config/*.json
couchdb-data
.idea
yarn.lock
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# docker build -t ohif/dicomweb-server:latest .
# docker run -p 5985:5985 ohif/dicomweb-server:latest
# If you want to use PouchDB in this container, add -p 5984:5984
# docker run -p 5985:5985 -p 5984:5984 -e USE_POUCHDB=true -e DB_SERVER=http://0.0.0.0 ohif/dicomweb-server:latest
FROM node:13.10.1-slim

# Install prerequisites
RUN apt-get update
RUN apt-get -y install supervisor

USER node
RUN mkdir -p /home/node/app
RUN mkdir -p /home/node/log/supervisor
WORKDIR /home/node/app
ADD . /home/node/app

# Restore deps
RUN npm ci
RUN npm install [email protected]

ENV USE_POUCHDB=false

EXPOSE 5984 5985
CMD ["supervisord", "-n", "-c", "/home/node/app/dockersupport/supervisord.conf"]
38 changes: 38 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# docker-compose up
# curl -X PUT http://127.0.0.1:5984/_users
# curl -X PUT http://127.0.0.1:5984/_replicator
# curl -X PUT http://127.0.0.1:5984/_global_changes
# curl -X PUT http://127.0.0.1:5984/chronicle
# http://localhost:5984/_utils/
version: '3.8'

services:
dicomweb:
build:
context: .
dockerfile: Dockerfile
image: ohif/dicomweb-server:latest
hostname: dicomweb-server
environment:
- PORT=5984
- DB_SERVER=http://couchdb
ports:
- '5985:5985'
depends_on:
- couchdb
restart: unless-stopped

##
# LINK: https://hub.docker.com/_/couchdb
##
couchdb:
image: couchdb:2.3.1
hostname: couchdb
volumes:
- ./couchdb-data:/opt/couchdb/data
environment:
- COUCHDB_USER=admin
- COUCHDB_PASSWORD=password
ports:
- '5984:5984'
restart: unless-stopped
9 changes: 9 additions & 0 deletions dockersupport/conditionally-start-pouchdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [ $USE_POUCHDB = "true" ]
then
echo "USE_POUCHDB is true, starting PouchDB service"
/home/node/app/node_modules/pouchdb-server/bin/pouchdb-server --in-memory --host 0.0.0.0
else
exit 0
fi
3 changes: 3 additions & 0 deletions dockersupport/dicomweb-server-service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
cd /home/node/app
npm start
16 changes: 16 additions & 0 deletions dockersupport/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[supervisord]
user=node
logfile=/home/node/log/supervisor/supervisord.log
nodaemon=true

[program:pouchdb]
command=bash /home/node/app/dockersupport/conditionally-start-pouchdb.sh
stdout_logfile=/home/node/log/supervisor/%(program_name)s.log
stderr_logfile=/home/node/log/supervisor/%(program_name)s.log
autorestart=true

[program:dicomweb-server]
command=bash /home/node/app/dockersupport/dicomweb-server-service.sh
stdout_logfile=/home/node/log/supervisor/%(program_name)s.log
stderr_logfile=/home/node/log/supervisor/%(program_name)s.log
autorestart=true
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "dicomweb-server",
"version": "0.0.0-development",
"description": "Lightweight DICOMweb Server with CouchDB",
"repository": "https://github.com/dcmjs-org/dicomweb-server",
"main": "server.js",
"dependencies": {
"atob": "^2.1.2",
Expand Down