kidcoconut
commited on
Commit
•
0f947fa
1
Parent(s):
bd1977f
Update Dockerfile
Browse files- Dockerfile +77 -77
Dockerfile
CHANGED
@@ -1,77 +1,77 @@
|
|
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 |
-
|
61 |
-
#--- to tag the image prior to push to DockerHub; docker login and then register user/image:tag
|
62 |
-
#--- to push this image to DockerHub, example based on the repo: kidcoconut73/img_stm_omdenasaudi_hcc
|
63 |
-
# docker tag img_omdenasaudi_hcc:0.1 kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
64 |
-
# docker tag img_omdenasaudi_hcc:0.1 kidcoconut73/img_stm_omdenasaudi_hcc:0.1
|
65 |
-
# docker push kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
66 |
-
|
67 |
-
#--- to run the container from the image; specific port mapping (-p) vs any available port mapping (-P)
|
68 |
-
# docker run -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc -v ./data:/app/data img_stm_omdenasaudi_hcc:0.1
|
69 |
-
# docker run -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc img_stm_omdenasaudi_hcc:0.1
|
70 |
-
# docker run -P --name ctr_stmOmdenaHcc img_stm_omdenasaudi_hcc:0.1 #--- open all ports defined by Docker EXPOSE
|
71 |
-
|
72 |
-
#--- ISSUE: uvicorn bug does not allow ctl-C break of fastapi through terminal
|
73 |
-
#--- WORKAROUND: you have to run a docker or docker compose kill cmd; eg docker kill <ctr_name>
|
74 |
-
|
75 |
-
|
76 |
-
#--- Docker build log
|
77 |
-
# from python:3.10.9-slim-bullseye size: 4.21gb time: >yyys
|
|
|
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 |
+
|
61 |
+
#--- to tag the image prior to push to DockerHub; docker login and then register user/image:tag
|
62 |
+
#--- to push this image to DockerHub, example based on the repo: kidcoconut73/img_stm_omdenasaudi_hcc
|
63 |
+
# docker tag img_omdenasaudi_hcc:0.1 kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
64 |
+
# docker tag img_omdenasaudi_hcc:0.1 kidcoconut73/img_stm_omdenasaudi_hcc:0.1
|
65 |
+
# docker push kidcoconut73/img_stm_omdenasaudi_hcc:demo
|
66 |
+
|
67 |
+
#--- to run the container from the image; specific port mapping (-p) vs any available port mapping (-P)
|
68 |
+
# docker run -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc -v ./data:/app/data img_stm_omdenasaudi_hcc:0.1
|
69 |
+
# docker run -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc img_stm_omdenasaudi_hcc:0.1
|
70 |
+
# docker run -P --name ctr_stmOmdenaHcc img_stm_omdenasaudi_hcc:0.1 #--- open all ports defined by Docker EXPOSE
|
71 |
+
|
72 |
+
#--- ISSUE: uvicorn bug does not allow ctl-C break of fastapi through terminal
|
73 |
+
#--- WORKAROUND: you have to run a docker or docker compose kill cmd; eg docker kill <ctr_name>
|
74 |
+
|
75 |
+
|
76 |
+
#--- Docker build log
|
77 |
+
# from python:3.10.9-slim-bullseye size: 4.21gb time: >yyys
|