Skip to content

Commit

Permalink
create standalone production config
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Budras authored and Tim Budras committed Sep 30, 2024
1 parent 8b1b26c commit d4e70aa
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 5 deletions.
101 changes: 101 additions & 0 deletions docker-compose-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
version: "3"
networks:
ezbids:

services:
mongodb:
container_name: brainlife_ezbids-mongodb
image: mongo:4.4.15
platform: linux/amd64
volumes:
- /data/db
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongo localhost:27017/test --quiet
interval: 10s
timeout: 10s
retries:
5
networks:
- ezbids

api:
container_name: brainlife_ezbids-api
build: .
platform: linux/amd64
volumes:
- ./api:/app/api
- /tmp:/tmp
depends_on:
mongodb:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8082/health"]
working_dir: /app/api
command:
./dev.sh
environment:
MONGO_CONNECTION_STRING: mongodb://mongodb:27017/ezbids
BRAINLIFE_AUTHENTICATION: ${BRAINLIFE_AUTHENTICATION}
networks:
- ezbids

handler:
container_name: brainlife_ezbids-handler
build: ./handler
platform: linux/amd64
volumes:
- .:/app
- /tmp:/tmp
depends_on:
mongodb:
condition: service_healthy
api:
condition: service_healthy
environment:
MONGO_CONNECTION_STRING: mongodb://mongodb:27017/ezbids
networks:
- ezbids
tty: true #turn on color for bids-validator output
command: pm2 start handler.js --attach

ui:
container_name: brainlife_ezbids-ui-builder
env_file:
- .env
build: ./ui/Dockerfile-production
platform: linux/amd64
volumes:
- ./ui/dist:/ui/dist
environment:
VITE_APIHOST: https://${SERVER_NAME}/api
VITE_BRAINLIFE_AUTHENTICATION: ${BRAINLIFE_AUTHENTICATION}

# by default this is not enabled, need to run docker compose with --profile development to enable this service
telemetry:
container_name: brainlife_ezbids-telemetry
build: ./telemetry
platform: linux/amd64
depends_on:
- mongodb
profiles: ["development"]
networks:
- ezbids

nginx:
env_file:
- .env
container_name: brainlife_ezbids-nginx
depends_on:
- ui
- api
image: nginx:latest
platform: linux/amd64
ports:
- 80:80
- 443:443
networks:
- ezbids
volumes:
- ./nginx/ssl:/etc/nginx/conf.d/ssl/
- ./nginx/production_nginx.conf:/etc/nginx/conf.d/default.conf
- ./ui/dist:/usr/share/nginx/html/ezbids:ro
2 changes: 1 addition & 1 deletion handler/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV DEBIAN_FRONTEND noninteractive
RUN apt update && \
apt-get update && apt-get upgrade -y

RUN apt install -y parallel python3 python3-pip tree curl unzip git jq python libgl-dev python-numpy bc
RUN apt update && apt install -y parallel python3 python3-pip tree curl unzip git jq python libgl-dev python-numpy bc

RUN pip3 install numpy==1.23.0 nibabel==4.0.0 pandas matplotlib pyyaml==5.4.1 pydicom==2.3.1 natsort pydeface && \
pip3 install quickshear mne mne-bids
Expand Down
10 changes: 6 additions & 4 deletions nginx/production_nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ server {

#access_log /var/log/nginx/host.access.log main;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
index index.html;

location = / {
return 301 /ezbids/;
}

location /ezbids {
proxy_pass http://ui:3000;
alias /usr/share/nginx/html/ezbids/;
try_files $uri $uri/ /ezbids/index.html;
}

location /api/ {
Expand Down
35 changes: 35 additions & 0 deletions prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

set -ex

BRAINLIFE_AUTHENTICATION=true
while getopts "d" flag; do
case $flag in
d)
BRAINLIFE_AUTHENTICATION=false
;;
\?)
;;
esac
done

export BRAINLIFE_AUTHENTICATION

git submodule update --init --recursive

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

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

./generate_keys.sh

# ok docker compose is now included in docker as an option for docker
if [[ $(command -v docker-compose) ]]; then
# if the older version is installed use the dash
docker-compose --file docker-compose-production.yml up
else
# if the newer version is installed don't use the dash
docker compose --file docker-compose-production.yml up
fi
9 changes: 9 additions & 0 deletions ui/Dockerfile-production
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:20

COPY . /ui
WORKDIR /ui

RUN npm install

CMD [ "npm", "run", "build"]

0 comments on commit d4e70aa

Please sign in to comment.