Commit
·
9b1bf0c
1
Parent(s):
ec523a8
prep for deploy of 0.1.4 to hugspace
Browse files- Dockerfile +22 -86
- Dockerfile.hub → Dockerfile.hug +7 -2
- Dockerfile.local +86 -0
Dockerfile
CHANGED
@@ -1,86 +1,22 @@
|
|
1 |
-
#---
|
2 |
-
|
3 |
-
#
|
4 |
-
|
5 |
-
|
6 |
-
#---
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
#
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
#---
|
22 |
-
|
23 |
-
|
24 |
-
# Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
|
25 |
-
#RUN pip install --no-cache-dir --upgrade pip
|
26 |
-
|
27 |
-
|
28 |
-
#--- copy only the requirements.txt file
|
29 |
-
#--- set docker image working directory to /app
|
30 |
-
#--- Not: this is reorg'd in an attempt to reduce the rebuilding of layers
|
31 |
-
COPY --chown=user ./requirements.txt $HOME/app/requirements.txt
|
32 |
-
COPY --chown=user ./packages.txt $HOME/app/packages.txt
|
33 |
-
|
34 |
-
#--- install all lib dependencies into the image
|
35 |
-
#RUN pip3 install -r $HOME/app/requirements.txt
|
36 |
-
RUN pip install --no-cache-dir --upgrade -r $HOME/app/requirements.txt
|
37 |
-
#RUN apt-get update -y && apt-get install -y ffmpeg libsm6 libxext6
|
38 |
-
|
39 |
-
#--- copy all files from the local pwd to the docker image /app folder
|
40 |
-
#--- .dockerignore: ensure no local data folders or files (images) are copied into the docker image/container
|
41 |
-
COPY --chown=user . $HOME/app
|
42 |
-
|
43 |
-
#--- for streamlit; external 49400; internal 39400
|
44 |
-
# localExec: (from root folder) streamlit run app.py --server.port=39400 --server.maxUploadSize=2000
|
45 |
-
EXPOSE 49400
|
46 |
-
#CMD ["streamlit", "run", "app.py", "--server.port=39400", "--server.maxUploadSize=2000"]
|
47 |
-
|
48 |
-
#--- for fastapi; external 49500; internal 39500
|
49 |
-
# localExec: (from root folder) uvicorn main:app --reload --workers 1 --host 0.0.0.0 --port 39500
|
50 |
-
EXPOSE 49500
|
51 |
-
#CMD ["uvicorn", "main:app", "--reload", "--host=0.0.0.0", "--port=39500"]
|
52 |
-
|
53 |
-
#--- start streamlit and fastapi from a helper utility script
|
54 |
-
#CMD ./util_startLocal_streamlitFastApi.sh
|
55 |
-
CMD $HOME/app/scripts/docker/util_docker_preRun.sh
|
56 |
-
|
57 |
-
|
58 |
-
#--- to build/rebuild the image; make sure you stop and remove the container if you are replacing/upgrading; or change the version tag# from 0.1
|
59 |
-
# docker build -t img_stm_omdenasaudi_hcc:0.1 .
|
60 |
-
# docker build -t img_stm_omdenasaudi_hcc:0.1.3 .
|
61 |
-
|
62 |
-
#--- build/rebuild the image from an alt Dockerfile
|
63 |
-
# docker build -t foo/bar -f /path/to/Dockerfile /path/to/
|
64 |
-
# docker build -t img_stm_omdenasaudi_hcc:0.1.4 -f Dockerfile.hub ./
|
65 |
-
|
66 |
-
#--- to tag the image prior to push to DockerHub; docker login and then register user/image:tag
|
67 |
-
#--- to push this image to DockerHub, example based on the repo: kidcoconut73/img_stm_omdenasaudi_hcc
|
68 |
-
# docker tag img_stm_omdenasaudi_hcc:0.1 kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
69 |
-
# docker tag img_stm_omdenasaudi_hcc:0.1 kidcoconut73/img_stm_omdenasaudi_hcc:0.1
|
70 |
-
# docker push kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
71 |
-
|
72 |
-
#--- to run the container from the image; specific port mapping (-p) vs any available port mapping (-P)
|
73 |
-
# docker run -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc -v ./data:/app/data img_stm_omdenasaudi_hcc:0.1
|
74 |
-
# docker run -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc img_stm_omdenasaudi_hcc:0.1
|
75 |
-
# docker run -P --name ctr_stmOmdenaHcc img_stm_omdenasaudi_hcc:0.1 #--- open all ports defined by Docker EXPOSE
|
76 |
-
|
77 |
-
#--- to run the container in interactive mode (local debug)
|
78 |
-
# docker run -it -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc_013 img_stm_omdenasaudi_hcc:0.1.3
|
79 |
-
|
80 |
-
#--- ISSUE: uvicorn bug does not allow ctl-C break of fastapi through terminal
|
81 |
-
#--- WORKAROUND: you have to run a docker or docker compose kill cmd; eg docker kill <ctr_name>
|
82 |
-
|
83 |
-
|
84 |
-
#--- Docker build log
|
85 |
-
# from python:3.10.9-slim-bullseye size: 4.21gb time: >yyys
|
86 |
-
# from python:3.10.9-slim-bullseye size: 4.21gb time: >3500s :0.13 expose streamlit 49400
|
|
|
1 |
+
#--- build the image from dockerHub
|
2 |
+
FROM kidcoconut73/img_stm_omdenasaudi_hcc:0.1.4
|
3 |
+
#FROM kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
4 |
+
|
5 |
+
|
6 |
+
#--- for streamlit; external 49400; internal 39400
|
7 |
+
#--- for fastapi; external 49500; internal 39500
|
8 |
+
|
9 |
+
|
10 |
+
#--- build/rebuild the image from an alt Dockerfile
|
11 |
+
# docker build -t foo/bar -f /path/to/Dockerfile /path/to/
|
12 |
+
# docker build -t img_stm_omdenasaudi_hcc:0.1.4 -f Dockerfile.hub ./
|
13 |
+
|
14 |
+
#--- create a container from an image (without running it)
|
15 |
+
# docker create -it -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaHcc_demo kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
16 |
+
|
17 |
+
#--- to run the container (interactive) from the image; specific port mapping (-p) vs any available port mapping (-P)
|
18 |
+
# docker run -it -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaHcc_demo img_stm_omdenasaudi_hcc:0.1.4
|
19 |
+
# docker run -it -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaHcc_demo kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
20 |
+
|
21 |
+
#--- start an existing container
|
22 |
+
# docker start -it ctr_stmOmdenaHcc_demo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dockerfile.hub → Dockerfile.hug
RENAMED
@@ -1,5 +1,6 @@
|
|
1 |
#--- build the image from dockerHub
|
2 |
-
FROM kidcoconut73/img_stm_omdenasaudi_hcc:
|
|
|
3 |
|
4 |
|
5 |
#--- for streamlit; external 49400; internal 39400
|
@@ -18,4 +19,8 @@ FROM kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
|
18 |
# docker run -it -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaHcc_demo kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
19 |
|
20 |
#--- start an existing container
|
21 |
-
# docker start -it ctr_stmOmdenaHcc_demo
|
|
|
|
|
|
|
|
|
|
1 |
#--- build the image from dockerHub
|
2 |
+
FROM kidcoconut73/img_stm_omdenasaudi_hcc:0.1.4
|
3 |
+
#FROM kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
4 |
|
5 |
|
6 |
#--- for streamlit; external 49400; internal 39400
|
|
|
19 |
# docker run -it -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaHcc_demo kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
20 |
|
21 |
#--- start an existing container
|
22 |
+
# docker start -it ctr_stmOmdenaHcc_demo
|
23 |
+
|
24 |
+
#--- deploy to huggingspace
|
25 |
+
# overwrite Dockerfile; cp Dockerfile.hug Dockerfile
|
26 |
+
# push to Huggingspace;
|
Dockerfile.local
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#--- PREREQS:
|
2 |
+
# - create a local folder dedicated to WSI image mgmt: (docker pwd)/data
|
3 |
+
# - populate the folder with raw data, wsi and tiles
|
4 |
+
# - docker run --name <name> -v <local folder>
|
5 |
+
|
6 |
+
#--- utilize a light linux distro for python apps
|
7 |
+
FROM python:3.10.9-slim-bullseye
|
8 |
+
|
9 |
+
RUN pip install --no-cache-dir --upgrade pip
|
10 |
+
RUN apt-get update -y && apt-get install -y ffmpeg libsm6 libxext6
|
11 |
+
|
12 |
+
# Set up a new user named "user" with user ID 1000
|
13 |
+
# Switch to the "user" user
|
14 |
+
RUN useradd -m -u 1000 user
|
15 |
+
USER user
|
16 |
+
|
17 |
+
# Set home to the user's home directory
|
18 |
+
ENV HOME=/home/user \
|
19 |
+
PATH=/home/user/.local/bin:$PATH
|
20 |
+
|
21 |
+
#--- set docker image working directory to /app
|
22 |
+
WORKDIR $HOME/app
|
23 |
+
|
24 |
+
# Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
|
25 |
+
#RUN pip install --no-cache-dir --upgrade pip
|
26 |
+
|
27 |
+
|
28 |
+
#--- copy only the requirements.txt file
|
29 |
+
#--- set docker image working directory to /app
|
30 |
+
#--- Not: this is reorg'd in an attempt to reduce the rebuilding of layers
|
31 |
+
COPY --chown=user ./requirements.txt $HOME/app/requirements.txt
|
32 |
+
COPY --chown=user ./packages.txt $HOME/app/packages.txt
|
33 |
+
|
34 |
+
#--- install all lib dependencies into the image
|
35 |
+
#RUN pip3 install -r $HOME/app/requirements.txt
|
36 |
+
RUN pip install --no-cache-dir --upgrade -r $HOME/app/requirements.txt
|
37 |
+
#RUN apt-get update -y && apt-get install -y ffmpeg libsm6 libxext6
|
38 |
+
|
39 |
+
#--- copy all files from the local pwd to the docker image /app folder
|
40 |
+
#--- .dockerignore: ensure no local data folders or files (images) are copied into the docker image/container
|
41 |
+
COPY --chown=user . $HOME/app
|
42 |
+
|
43 |
+
#--- for streamlit; external 49400; internal 39400
|
44 |
+
# localExec: (from root folder) streamlit run app.py --server.port=39400 --server.maxUploadSize=2000
|
45 |
+
EXPOSE 49400
|
46 |
+
#CMD ["streamlit", "run", "app.py", "--server.port=39400", "--server.maxUploadSize=2000"]
|
47 |
+
|
48 |
+
#--- for fastapi; external 49500; internal 39500
|
49 |
+
# localExec: (from root folder) uvicorn main:app --reload --workers 1 --host 0.0.0.0 --port 39500
|
50 |
+
EXPOSE 49500
|
51 |
+
#CMD ["uvicorn", "main:app", "--reload", "--host=0.0.0.0", "--port=39500"]
|
52 |
+
|
53 |
+
#--- start streamlit and fastapi from a helper utility script
|
54 |
+
#CMD ./util_startLocal_streamlitFastApi.sh
|
55 |
+
CMD $HOME/app/scripts/docker/util_docker_preRun.sh
|
56 |
+
|
57 |
+
|
58 |
+
#--- to build/rebuild the image; make sure you stop and remove the container if you are replacing/upgrading; or change the version tag# from 0.1
|
59 |
+
# docker build -t img_stm_omdenasaudi_hcc:0.1 .
|
60 |
+
# docker build -t img_stm_omdenasaudi_hcc:0.1.3 .
|
61 |
+
|
62 |
+
#--- build/rebuild the image from an alt Dockerfile
|
63 |
+
# docker build -t foo/bar -f /path/to/Dockerfile /path/to/
|
64 |
+
# docker build -t img_stm_omdenasaudi_hcc:0.1.4 -f Dockerfile.hub ./
|
65 |
+
|
66 |
+
#--- to tag the image prior to push to DockerHub; docker login and then register user/image:tag
|
67 |
+
#--- to push this image to DockerHub, example based on the repo: kidcoconut73/img_stm_omdenasaudi_hcc
|
68 |
+
# docker tag img_stm_omdenasaudi_hcc:0.1 kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
69 |
+
# docker tag img_stm_omdenasaudi_hcc:0.1 kidcoconut73/img_stm_omdenasaudi_hcc:0.1
|
70 |
+
# docker push kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
71 |
+
|
72 |
+
#--- to run the container from the image; specific port mapping (-p) vs any available port mapping (-P)
|
73 |
+
# docker run -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc -v ./data:/app/data img_stm_omdenasaudi_hcc:0.1
|
74 |
+
# docker run -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc img_stm_omdenasaudi_hcc:0.1
|
75 |
+
# docker run -P --name ctr_stmOmdenaHcc img_stm_omdenasaudi_hcc:0.1 #--- open all ports defined by Docker EXPOSE
|
76 |
+
|
77 |
+
#--- to run the container in interactive mode (local debug)
|
78 |
+
# docker run -it -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc_013 img_stm_omdenasaudi_hcc:0.1.3
|
79 |
+
|
80 |
+
#--- ISSUE: uvicorn bug does not allow ctl-C break of fastapi through terminal
|
81 |
+
#--- WORKAROUND: you have to run a docker or docker compose kill cmd; eg docker kill <ctr_name>
|
82 |
+
|
83 |
+
|
84 |
+
#--- Docker build log
|
85 |
+
# from python:3.10.9-slim-bullseye size: 4.21gb time: >yyys
|
86 |
+
# from python:3.10.9-slim-bullseye size: 4.21gb time: >3500s :0.13 expose streamlit 49400
|