alessandro trinca tornidor commited on
Commit
05cef9e
1 Parent(s): 90dbc1a

[feat] add Dockerfile, update README.md

Browse files
Files changed (3) hide show
  1. Dockerfile +22 -0
  2. README.md +19 -1
  3. scripts/entrypoint.sh +24 -0
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-bookworm AS builder_global
2
+
3
+ ARG PACKAGE_NAME="app_gradio_fastapi"
4
+ ARG ROOT_DIR="/code"
5
+ WORKDIR ${ROOT_DIR}
6
+ RUN chmod 770 -R ${ROOT_DIR}/
7
+
8
+ COPY ./requirements.txt ${ROOT_DIR}/requirements.txt
9
+
10
+ RUN pip install pip --upgrade
11
+ RUN python -m venv venv
12
+ RUN . ${ROOT_DIR}/venv/bin/activate && pip install --no-cache-dir -r ${ROOT_DIR}/requirements.txt
13
+
14
+ COPY ./scripts ${ROOT_DIR}/scripts
15
+ COPY ./${PACKAGE_NAME} ${ROOT_DIR}/${PACKAGE_NAME}
16
+
17
+ RUN chmod +x ${ROOT_DIR}/scripts/entrypoint.sh
18
+
19
+ EXPOSE 7860
20
+
21
+ CMD ["/code/scripts/entrypoint.sh"]
22
+ # CMD ["uvicorn", "wrappers.main:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -1,4 +1,5 @@
1
- # Run the app
 
2
 
3
  1. create and activate a virtual environment
4
  2. install the dependencies
@@ -14,3 +15,20 @@ python -m pip install -r requirements.txt
14
  # execute the uvicorn webserver
15
  uvicorn app_gradio_fastapi.main:app --host 0.0.0.0 --port 7860 --reload
16
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gradio plus FastAPI with UUID logging sessions
2
+ ## Run the app in a virtual environment
3
 
4
  1. create and activate a virtual environment
5
  2. install the dependencies
 
15
  # execute the uvicorn webserver
16
  uvicorn app_gradio_fastapi.main:app --host 0.0.0.0 --port 7860 --reload
17
  ```
18
+
19
+ ## Run the app within a docker container
20
+
21
+ Build the docker image and run the container:
22
+
23
+ ```bash
24
+ docker build . --tag app_gradio_fastapi --progress=plain
25
+ docker run -d --name app_gradio_fastapi -p 7860:7860 app_gradio_fastapi; docker logs -f app_gradio_fastapi
26
+ ```
27
+
28
+ To stop all the container and remove all the docker images:
29
+
30
+
31
+ ```bash
32
+ docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)
33
+ docker rmi $(docker images -q) -f
34
+ ```
scripts/entrypoint.sh ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ WORKDIR="/code"
4
+
5
+ cd ${WORKDIR} || exit
6
+ pwd
7
+ source ${WORKDIR}/venv/bin/activate
8
+
9
+ which python
10
+ python --version
11
+ which pip
12
+ pip --version
13
+
14
+ free -m
15
+ pip list
16
+ ls -l
17
+ echo "uvicorn"
18
+ ls -l ${WORKDIR}/venv/bin/uvicorn
19
+
20
+ # python ${WORKDIR}/app.py --version='xinlai/LISA-13B-llama2-v1-explanatory' --precision='fp16' --load_in_4bit
21
+ echo "${WORKDIR}/venv/bin/uvicorn app_gradio_fastapi.main:app --host 0.0.0.0 --port 7860"
22
+ ${WORKDIR}/venv/bin/uvicorn app_gradio_fastapi.main:app --host 0.0.0.0 --port 7860
23
+
24
+ exit 0