andreped commited on
Commit
9ba9eff
1 Parent(s): 33b50d5

Reworked OHIF docker build setup

Browse files
.docker/Viewer-v3.x/default.conf.template DELETED
@@ -1,16 +0,0 @@
1
- server {
2
- listen ${PORT} default_server;
3
- listen [::]:${PORT} default_server;
4
- location / {
5
- root /usr/share/nginx/html;
6
- index index.html index.htm;
7
- try_files $uri $uri/ /index.html;
8
- add_header Cross-Origin-Opener-Policy same-origin;
9
- add_header Cross-Origin-Embedder-Policy require-corp;
10
- add_header Cross-Origin-Resource-Policy same-origin;
11
- proxy_set_header Host $host;
12
- proxy_set_header X-Real-IP $remote_addr;
13
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
14
- proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
15
- }
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.docker/Viewer-v3.x/default.conf_old.template DELETED
@@ -1,21 +0,0 @@
1
- server {
2
- listen ${PORT} default_server;
3
- listen [::]:${PORT} default_server;
4
- location / {
5
- root /usr/share/nginx/html;
6
- index index.html index.htm;
7
- try_files $uri $uri/ /index.html;
8
- add_header Cross-Origin-Opener-Policy same-origin;
9
- add_header Cross-Origin-Embedder-Policy require-corp;
10
- add_header Cross-Origin-Resource-Policy same-origin;
11
- proxy_set_header Host $host;
12
- proxy_set_header X-Real-IP $remote_addr;
13
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
14
- proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
15
- }
16
- error_page 500 502 503 504 /50x.html;
17
- location = /50x.html {
18
- location = /50x.html {
19
- root /usr/share/nginx/html;
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.docker/Viewer-v3.x/entrypoint.sh DELETED
@@ -1,45 +0,0 @@
1
- #!/bin/sh
2
-
3
- if [ -n "$SSL_PORT" ]
4
- then
5
- envsubst '${SSL_PORT}:${PORT}' < /usr/src/default.ssl.conf.template > /etc/nginx/conf.d/default.conf
6
- else
7
- envsubst '${PORT}' < /usr/src/default.conf.template > /etc/nginx/conf.d/default.conf
8
- fi
9
-
10
- if [ -n "$APP_CONFIG" ]
11
- then
12
- echo "$APP_CONFIG" > /usr/share/nginx/html/app-config.js
13
- fi
14
-
15
- if [ -n "$CLIENT_ID" ] || [ -n "$HEALTHCARE_API_ENDPOINT" ]
16
- then
17
- # If CLIENT_ID is specified, use the google.js configuration with the modified ID
18
- if [ -n "$CLIENT_ID" ]
19
- then
20
- echo "Google Cloud Healthcare \$CLIENT_ID has been provided: "
21
- echo "$CLIENT_ID"
22
- echo "Updating config..."
23
-
24
- # - Use SED to replace the CLIENT_ID that is currently in google.js
25
- sed -i -e "s/YOURCLIENTID.apps.googleusercontent.com/$CLIENT_ID/g" /usr/share/nginx/html/google.js
26
- fi
27
-
28
- # If HEALTHCARE_API_ENDPOINT is specified, use the google.js configuration with the modified endpoint
29
- if [ -n "$HEALTHCARE_API_ENDPOINT" ]
30
- then
31
- echo "Google Cloud Healthcare \$HEALTHCARE_API_ENDPOINT has been provided: "
32
- echo "$HEALTHCARE_API_ENDPOINT"
33
- echo "Updating config..."
34
-
35
- # - Use SED to replace the HEALTHCARE_API_ENDPOINT that is currently in google.js
36
- sed -i -e "s+https://healthcare.googleapis.com/v1+$HEALTHCARE_API_ENDPOINT+g" /usr/share/nginx/html/google.js
37
- fi
38
-
39
- # - Copy google.js to overwrite app-config.js
40
- cp /usr/share/nginx/html/google.js /usr/share/nginx/html/app-config.js
41
- fi
42
-
43
- echo "Starting Nginx to serve the OHIF Viewer..."
44
-
45
- exec "$@"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
Dockerfile CHANGED
@@ -1,67 +1,56 @@
1
- FROM ohif/app:v3.7.0-beta.74
2
 
3
- # first set user as root to add new user (then later change to user)
4
- USER root
5
-
6
- # To install usermod in Alpine Linux
7
- #RUN echo http://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories
8
- #RUN apk add -U shadow
9
-
10
- # change user ID of "nginx" to 1000 to work with HF spaces
11
- # RUN find / -uid 1000 -exec chown -h 1000 {} +
12
- #RUN usermod -u 1000 nginx
13
-
14
- USER nginx
15
-
16
- # Set port as environmental variable for reverse proxy
17
- # ENV PORT=80
18
-
19
- RUN ls
20
-
21
- # Set home to the user's home directory
22
- ENV HOME=/home/user \
23
- PATH=/home/user/.local/bin:$PATH
24
 
25
- # Set the working directory to the user's home directory
26
- WORKDIR $HOME/app
27
 
28
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
29
- #COPY --chown=nginx . $HOME/app
 
 
30
 
31
- # change to nginx user
32
- #USER nginx
 
 
33
 
34
- #USER user
 
 
 
 
35
 
36
- # Copy nginx configuration
37
- #COPY --chown=nginx nginx.conf /etc/nginx/sites-available/default
38
- #COPY --chown=nginx .docker/Viewer-v3.x/default.conf.template /usr/src/default.conf.template
39
- COPY --chown=nginx:nginx .docker/Viewer-v3.x /usr/src
40
- RUN chmod 777 /usr/src/entrypoint.sh
41
 
42
- #RUN chmod 777 /usr/src/entrypoint.sh
 
 
43
 
44
- #COPY --chown=nginx . .
45
 
46
- # RUN rm /etc/nginx/conf.d/default.conf
 
47
 
48
- #USER nginx
49
- #COPY --chown=nginx:nginx .docker/Viewer-v3.x /usr/src
50
- #RUN chmod 777 /usr/src/entrypoint.sh
 
51
 
52
- #RUN chmod +x /usr/src/entrypoint.sh
53
-
54
- # reverse proxy server
55
- #EXPOSE 80
56
- #EXPOSE 80/tcp
57
- #EXPOSE 3000
58
-
59
- # change back to nginx user
60
- #USER nginx
61
-
62
- ENTRYPOINT ["/usr/src/entrypoint.sh"]
63
-
64
- # Launch nginx
 
65
  CMD ["nginx", "-g", "daemon off;"]
66
-
67
- #CMD ["bash", "run.sh"]
 
1
+ FROM node:16.15.0-slim as json-copier
2
 
3
+ RUN mkdir /usr/src/app
4
+ WORKDIR /usr/src/app
5
+ # Clone the application
6
+ RUN apt-get update && apt-get install -y git
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
+ RUN git clone --recursive https://github.com/OHIF/Viewers.git .
 
9
 
10
+ # # COPY ["package.json", "yarn.lock", "preinstall.js", "./"]
11
+ # COPY extensions /usr/src/app/extensions
12
+ # COPY modes /usr/src/app/modes
13
+ # COPY platform /usr/src/app/platform
14
 
15
+ # Find and remove non-package.json files
16
+ #RUN find extensions \! -name "package.json" -mindepth 2 -maxdepth 2 -print | xargs rm -rf
17
+ #RUN find modes \! -name "package.json" -mindepth 2 -maxdepth 2 -print | xargs rm -rf
18
+ #RUN find platform \! -name "package.json" -mindepth 2 -maxdepth 2 -print | xargs rm -rf
19
 
20
+ # Copy Files
21
+ FROM node:16.15.0-slim as builder
22
+ RUN apt-get update && apt-get install -y build-essential python3
23
+ RUN mkdir /usr/src/app
24
+ WORKDIR /usr/src/app
25
 
26
+ COPY --from=json-copier /usr/src/app .
 
 
 
 
27
 
28
+ # Run the install before copying the rest of the files
29
+ RUN yarn config set workspaces-experimental true
30
+ RUN yarn install --frozen-lockfile --verbose
31
 
32
+ COPY . .
33
 
34
+ # To restore workspaces symlinks
35
+ RUN yarn install --frozen-lockfile --verbose
36
 
37
+ ENV PATH /usr/src/app/node_modules/.bin:$PATH
38
+ ENV QUICK_BUILD true
39
+ # ENV GENERATE_SOURCEMAP=false
40
+ # ENV REACT_APP_CONFIG=config/default.js
41
 
42
+ RUN yarn run build
43
+ # Stage 3: Bundle the built application into a Docker container
44
+ # which runs Nginx using Alpine Linux
45
+ FROM nginxinc/nginx-unprivileged:1.25-alpine as final
46
+ #RUN apk add --no-cache bash
47
+ USER nginx
48
+ COPY --chown=nginx:nginx nginx.conf /etc/nginx/conf.d/default.conf
49
+ COPY --chown=nginx:nginx app-config.js /usr/share/nginx/html/app-config.js
50
+ COPY --from=builder /usr/src/app/platform/app/dist /usr/share/nginx/html
51
+ # In entrypoint.sh, app-config.js might be overwritten, so chmod it to be writeable.
52
+ # The nginx user cannot chmod it, so change to root.
53
+ USER root
54
+ RUN chmod 666 /usr/share/nginx/html/app-config.js
55
+ USER nginx
56
  CMD ["nginx", "-g", "daemon off;"]
 
 
README.md CHANGED
@@ -3,10 +3,13 @@ title: 'dsa4hf: Project to showcase AI solutions for medical applications in OHI
3
  colorFrom: indigo
4
  colorTo: indigo
5
  sdk: docker
6
- app_port: 3000
7
  emoji: 🔬
8
  pinned: false
9
  license: mit
 
 
 
 
10
  ---
11
 
12
  # ohif4hf
@@ -26,7 +29,7 @@ When the solution is ready, the website should be accessible on [Hugging Face](h
26
  ```
27
  git clone https://github.com/andreped/ohif4hf.git
28
  docker build --no-cache -t ohif4hf .
29
- docker run -p 3000:80 ohif4hf
30
  ```
31
 
32
  To go inside docker image and debug, at the bottom of the Dockerfile, add `ENTRYPOINT [ "/bin/sh" ]` before running.
 
3
  colorFrom: indigo
4
  colorTo: indigo
5
  sdk: docker
 
6
  emoji: 🔬
7
  pinned: false
8
  license: mit
9
+ custom_headers:
10
+ cross-origin-embedder-policy: require-corp
11
+ cross-origin-opener-policy: same-origin
12
+ cross-origin-resource-policy: cross-origin
13
  ---
14
 
15
  # ohif4hf
 
29
  ```
30
  git clone https://github.com/andreped/ohif4hf.git
31
  docker build --no-cache -t ohif4hf .
32
+ docker run -p 4444:7860 ohif4hf
33
  ```
34
 
35
  To go inside docker image and debug, at the bottom of the Dockerfile, add `ENTRYPOINT [ "/bin/sh" ]` before running.
app-config.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ window.config = {
2
+ routerBasename: "/",
3
+ extensions: [],
4
+ modes: [],
5
+ showStudyList: true,
6
+ dataSources: [
7
+ {
8
+ namespace: "@ohif/extension-default.dataSourcesModule.dicomweb",
9
+ sourceName: "dicomweb",
10
+ configuration: {
11
+ friendlyName: "dcmjs DICOMWeb Server",
12
+ name: "DCM4CHEE",
13
+ wadoUriRoot: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/wado",
14
+ qidoRoot: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
15
+ wadoRoot: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
16
+ qidoSupportsIncludeField: true,
17
+ supportsReject: true,
18
+ imageRendering: "wadors",
19
+ thumbnailRendering: "wadors",
20
+ enableStudyLazyLoad: true,
21
+ supportsFuzzyMatching: true,
22
+ supportsWildcard: true,
23
+ omitQuotationForMultipartRequest: true,
24
+ },
25
+ },
26
+ ],
27
+ defaultDataSourceName: "dicomweb",
28
+ };
nginx.conf CHANGED
@@ -1,24 +1,20 @@
1
  server {
2
- listen 3000 default_server;
3
- listen [::]:3000 default_server;
4
-
5
- root /usr/share/nginx/html;
6
- index index.html index.htm;
7
-
8
- server_name _;
9
- location / {
10
- # serve OHIF 3000
11
- proxy_pass http://localhost:80;
12
- proxy_set_header Host $host;
13
- proxy_set_header X-Real-IP $remote_addr;
14
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
15
- #proxy_set_header X-Forwarded-Proto $scheme;
16
- proxy_set_header X-Forwarded-Proto http;
17
- proxy_set_header X-Forwarded-Ssl off;
18
- proxy_set_header X-Url-Scheme http;
19
- proxy_buffering off;
20
- proxy_http_version 1.1;
21
- proxy_set_header Upgrade $http_upgrade;
22
- proxy_set_header Connection "upgrade";
23
- }
24
- }
 
1
  server {
2
+ listen 7860 default_server;
3
+ listen [::]:7860 default_server;
4
+ location / {
5
+ root /usr/share/nginx/html;
6
+ index index.html index.htm;
7
+ try_files $uri $uri/ /index.html;
8
+ add_header Cross-Origin-Opener-Policy same-origin;
9
+ add_header Cross-Origin-Embedder-Policy require-corp;
10
+ add_header Cross-Origin-Resource-Policy cross-origin;
11
+ proxy_set_header Host $host;
12
+ proxy_set_header X-Real-IP $remote_addr;
13
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
14
+ proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
15
+ }
16
+ error_page 500 502 503 504 /50x.html;
17
+ location = /50x.html {
18
+ root /usr/share/nginx/html;
19
+ }
20
+ }
 
 
 
 
nginx_old.conf DELETED
@@ -1,24 +0,0 @@
1
- server {
2
- listen 3000 default_server;
3
- listen [::]:3000 default_server;
4
-
5
- root /usr/share/nginx/html;
6
- index index.html index.htm;
7
-
8
- server_name _;
9
- location / {
10
- # serve OHIF 3000
11
- proxy_pass http://localhost:80;
12
- proxy_set_header Host $host;
13
- proxy_set_header X-Real-IP $remote_addr;
14
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
15
- #proxy_set_header X-Forwarded-Proto $scheme;
16
- proxy_set_header X-Forwarded-Proto http;
17
- proxy_set_header X-Forwarded-Ssl off;
18
- proxy_set_header X-Url-Scheme http;
19
- proxy_buffering off;
20
- proxy_http_version 1.1;
21
- proxy_set_header Upgrade $http_upgrade;
22
- proxy_set_header Connection "upgrade";
23
- }
24
- }