File size: 3,577 Bytes
b831e6f 0c31d60 19d6e02 dbe9102 227689b 6e30322 227689b dbe9102 227689b dc6eb0a dbe9102 6e30322 dc6eb0a dbe9102 b831e6f dbe9102 b831e6f dbe9102 b831e6f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
#--- PREREQS:
# - create a local folder dedicated to WSI image mgmt: (docker pwd)/data
# - populate the folder with raw data, wsi and tiles
# - docker run --name <name> -v <local folder>
#--- utilize a light linux distro for python apps
FROM python:3.10.9-slim-bullseye
# Set up a new user named "user" with user ID 1000
# Switch to the "user" user
RUN useradd -m -u 1000 user
USER user
# Set home to the user's home directory
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
#--- set docker image working directory to /app
WORKDIR $HOME/app
# Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
RUN pip install --no-cache-dir --upgrade pip
#--- copy only the requirements.txt file
#--- set docker image working directory to /app
#--- Not: this is reorg'd in an attempt to reduce the rebuilding of layers
COPY --chown=user ./requirements.txt $HOME/app/requirements.txt
COPY --chown=user ./packages.txt $HOME/app/packages.txt
#--- install all lib dependencies into the image
#RUN pip3 install -r $HOME/app/requirements.txt
#RUN pip install -r $HOME/app/requirements.txt
#RUN apt-get update -y && apt-get install -y ffmpeg libsm6 libxext6
#--- copy all files from the local pwd to the docker image /app folder
#--- .dockerignore: ensure no local data folders or files (images) are copied into the docker image/container
COPY --chown=user . $HOME/app
#--- for streamlit; external 49400; internal 39400
# localExec: (from root folder) streamlit run app.py --server.port=39400 --server.maxUploadSize=2000
EXPOSE 49400
#CMD ["streamlit", "run", "app.py", "--server.port=39400", "--server.maxUploadSize=2000"]
#--- for fastapi; external 49500; internal 39500
# localExec: (from root folder) uvicorn main:app --reload --workers 1 --host 0.0.0.0 --port 39500
EXPOSE 49500
#CMD ["uvicorn", "main:app", "--reload", "--host=0.0.0.0", "--port=39500"]
#--- start streamlit and fastapi from a helper utility script
#CMD ./util_startLocal_streamlitFastApi.sh
CMD $HOME/app/scripts/docker/util_docker_preRun.sh
#--- 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
# docker build -t img_stm_omdenasaudi_hcc:0.1 .
#--- to tag the image prior to push to DockerHub; docker login and then register user/image:tag
#--- to push this image to DockerHub, example based on the repo: kidcoconut73/img_stm_omdenasaudi_hcc
# docker tag img_omdenasaudi_hcc:0.1 kidcoconut73/img_stm_omdenasaudi_hcc:demo
# docker tag img_omdenasaudi_hcc:0.1 kidcoconut73/img_stm_omdenasaudi_hcc:0.1
# docker push kidcoconut73/img_stm_omdenasaudi_hcc:demo
#--- to run the container from the image; specific port mapping (-p) vs any available port mapping (-P)
# docker run -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc -v ./data:/app/data img_stm_omdenasaudi_hcc:0.1
# docker run -p 49400:39400 -p 49500:39500 --name ctr_stmOmdenaSaudiHcc img_stm_omdenasaudi_hcc:0.1
# docker run -P --name ctr_stmOmdenaHcc img_stm_omdenasaudi_hcc:0.1 #--- open all ports defined by Docker EXPOSE
#--- ISSUE: uvicorn bug does not allow ctl-C break of fastapi through terminal
#--- WORKAROUND: you have to run a docker or docker compose kill cmd; eg docker kill <ctr_name>
#--- Docker build log
# from python:3.10.9-slim-bullseye size: 4.21gb time: >yyys
|