Skip to content

Commit

Permalink
updated to use docker-compose for fully local development environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Soichi Hayashi committed Aug 24, 2022
1 parent 55c3fff commit b0b1539
Show file tree
Hide file tree
Showing 21 changed files with 3,130 additions and 79 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ui
handler
workdir
test
bids-specification
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:16

COPY . /app

WORKDIR /app
RUN npm install -g pm2 typescript

RUN npm install

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,11 @@ We ask that you the following articles when publishing papers that used data, co

1. Avesani, P., McPherson, B., Hayashi, S. et al. The open diffusion data derivatives, brain data upcycling via integrated publishing of derivatives and reproducible open cloud services. Sci Data 6, 69 (2019). [https://doi.org/10.1038/s41597-019-0073-y](https://doi.org/10.1038/s41597-019-0073-y)

### This repo was bootstrapped by

```
npm init vite@latest ui2 -- --template vue-ts
```

Copyright © 2020 brainlife.io at University of Texas at Austin and Indiana University

16 changes: 0 additions & 16 deletions api/config.js.sample

This file was deleted.

7 changes: 4 additions & 3 deletions api/controllers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/controllers.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ router.get('/health', (req, res, next) => {
status = "failed";
message = err;
}
res.json({status, message});
res.json({status, message, date: new Date()});
});

router.post('/session', (req, res, next)=>{
Expand Down
4 changes: 4 additions & 0 deletions api/dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

tsc --watch &
pm2 start ezbids.js --attach --watch --ignore-watch="*.log test *.sh ui bin example .git **/*.ts"
4 changes: 2 additions & 2 deletions api/ezbids.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions api/models.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/models.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion api/tsc.sh

This file was deleted.

1 change: 0 additions & 1 deletion create.sh

This file was deleted.

16 changes: 16 additions & 0 deletions dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -ex

git submodule update --init --recursive

(cd api && npm install)
(cd ui && npm install)

mkdir -p /tmp/upload
mkdir -p /tmp/workdir

#docker-compose up --build
docker-compose up


67 changes: 67 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: "3"

services:

mongodb:
image: mongo:4.4.15
volumes:
- /data/db
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongo localhost:27017/test --quiet
interval: 10s
timeout: 10s
retries: 5
ports:
- 27417:27017 #for local debuggin

api:
build: .
volumes:
- ./api:/app/api
- /tmp:/tmp
depends_on:
mongodb:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
working_dir: /app/api
command: ./dev.sh
ports:
- 8082:8080

handler:
build: ./handler
volumes:
- .:/app
- /tmp:/tmp
depends_on:
mongodb:
condition: service_healthy
tty:
true #turn on color for bids-validator output
command: pm2 start handler.js --attach --watch --ignore-watch "ui **/node_modules"

ui:
build: ./ui
volumes:
- ./ui/src:/ui/src #don't copy node_modules which might be compiled for mac (vite won't work)
environment:
VITE_APIHOST: http://localhost:8082
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
ports:
- 3000:3000

# nginx:
# image: nginx:1.18
# depends_on:
# api:
# condition: service_healthy
# ui:
# condition: service_healthy
# volumes:
# - ./config/nginx/nginx.conf:/etc/nginx/nginx.conf
# ports:
# - 8082:80


27 changes: 17 additions & 10 deletions handler/container/Dockerfile → handler/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#FROM ubuntu:20.04
#FROM brainlife/fsl-mini:6.0.3
FROM neurodebian:nd20.04-non-free

ENV DEBIAN_FRONTEND noninteractive
Expand Down Expand Up @@ -28,18 +26,22 @@ RUN . $FSLDIR/etc/fslconf/fsl.sh
ENV FSLOUTPUTTYPE=NIFTI_GZ

#make sure fslpython is properly installed
RUN which imcp
#RUN which imcp

RUN apt install -y curl
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
RUN apt install -y nodejs

# Get dcm2niix from github and compile
RUN cd /tmp && \
git clone https://github.com/rordenlab/dcm2niix.git -b v1.0.20211006 && \
cd dcm2niix && mkdir build && cd build && \
cmake -DBATCH_VERSION=ON -DUSE_OPENJPEG=ON .. && \
make && make install
#RUN cd /tmp && \
# git clone https://github.com/rordenlab/dcm2niix.git -b v1.0.20211006 && \
# cd dcm2niix && mkdir build && cd build && \
# cmake -DBATCH_VERSION=ON -DUSE_OPENJPEG=ON .. && \
# make && make install

RUN wget https://github.com/rordenlab/dcm2niix/releases/download/v1.0.20220720/dcm2niix_lnx.zip -O /tmp/dcm2niix_lnx.zip
RUN unzip /tmp/dcm2niix_lnx.zip
RUN mv dcm2niix /usr/local/bin

# Get bids-specification from github
RUN cd && git clone https://github.com/bids-standard/bids-specification
Expand All @@ -51,7 +53,9 @@ RUN pip3 install numpy nibabel pandas==1.0.1 matplotlib pyyaml==5.4.1 natsort #n
RUN pip3 install quickshear

#install ROBEX
COPY ROBEXv12.linux64.tar.gz /
#COPY ROBEXv12.linux64.tar.gz /
ADD https://www.nitrc.org/frs/download.php/5994/ROBEXv12.linux64.tar.gz//?i_agree=1&download_now=1 /
RUN ls -la
RUN tar -xzf /ROBEXv12.linux64.tar.gz
ENV PATH=$PATH:/ROBEX

Expand All @@ -61,8 +65,11 @@ RUN pip3 install pydeface
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

#install bids-validator
RUN npm install -g [email protected].3
RUN npm install -g [email protected].6

RUN apt-get install -y rename zstd

WORKDIR /app/handler
RUN npm install -g pm2 #for dev


8 changes: 0 additions & 8 deletions handler/build_container.sh

This file was deleted.

8 changes: 8 additions & 0 deletions ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:16

COPY . /ui
WORKDIR /ui

RUN npm install

CMD [ "npm", "run", "dev" ]
Loading

0 comments on commit b0b1539

Please sign in to comment.