Spaces:
Running
Running
Test deployment with app_port "3000:80"
Browse files- .docker/Viewer-v3.x/default.conf.template +16 -0
- .docker/Viewer-v3.x/default.conf_old.template +21 -0
- .docker/Viewer-v3.x/entrypoint.sh +45 -0
- Dockerfile +42 -14
- README.md +1 -1
- nginx.conf +24 -0
- nginx_old.conf +24 -0
.docker/Viewer-v3.x/default.conf.template
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 "$@"
|
Dockerfile
CHANGED
@@ -3,15 +3,20 @@ FROM ohif/app:v3.7.0-beta.74
|
|
3 |
# first set user as root to add new user (then later change to user)
|
4 |
USER root
|
5 |
|
6 |
-
#
|
7 |
-
#
|
8 |
-
RUN
|
9 |
|
10 |
-
#
|
11 |
-
|
|
|
|
|
|
|
12 |
|
13 |
# Set port as environmental variable for reverse proxy
|
14 |
-
ENV PORT=
|
|
|
|
|
15 |
|
16 |
# Set home to the user's home directory
|
17 |
ENV HOME=/home/user \
|
@@ -21,19 +26,42 @@ ENV HOME=/home/user \
|
|
21 |
WORKDIR $HOME/app
|
22 |
|
23 |
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
24 |
-
COPY --chown=
|
25 |
-
|
26 |
-
RUN ls
|
27 |
|
28 |
# change to nginx user
|
29 |
-
USER nginx
|
|
|
|
|
30 |
|
31 |
-
#
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
# reverse proxy server
|
36 |
-
EXPOSE
|
37 |
-
EXPOSE
|
|
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
CMD ["nginx", "-g", "daemon off;"]
|
|
|
|
|
|
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 \
|
|
|
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"]
|
README.md
CHANGED
@@ -3,7 +3,7 @@ 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
|
|
|
3 |
colorFrom: indigo
|
4 |
colorTo: indigo
|
5 |
sdk: docker
|
6 |
+
app_port: "3000:80"
|
7 |
emoji: 🔬
|
8 |
pinned: false
|
9 |
license: mit
|
nginx.conf
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|
nginx_old.conf
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|