demo commited on
Commit
fbbb171
1 Parent(s): 1322ef0

initial commit

Browse files
Files changed (3) hide show
  1. Dockerfile +9 -0
  2. README.md +50 -0
  3. requirements.txt +15 -0
Dockerfile ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+ #ARG GRADIO_SERVER_PORT=7000
3
+ #ENV GRADIO_SERVER_PORT=${GRADIO_SERVER_PORT}
4
+
5
+ RUN apt-get update && apt-get install -y python3 python3-pip
6
+ WORKDIR /code
7
+ COPY ./requirements.txt /code/requirements.txt
8
+ RUN pip install --no-cache-dir --upgrade pip
9
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
README.md CHANGED
@@ -9,3 +9,53 @@ license: cc0-1.0
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12
+
13
+ # Base Docker image for development
14
+
15
+ ## Purpose
16
+ This repo is used to test the creation of a base docker image that can serve as a starting image to develop webapps based on huggingface libraries. The image comes with common python dependencies installed. The purpose is to accelerate the dependencies installation for applications developed on top of this image.
17
+
18
+ ## How to use this repo
19
+
20
+ ### Create a repo for your web app
21
+ Start with creating a new repo for your app using your favorite git tool, i.e. local git repo, HuggingFace repo, GitHub, GitLab, etc.. In this document, we will refer to your new repo as ```$MY_WEBAPP_REPO```
22
+
23
+ ### Write your app and its dependencies
24
+ Create a Dockerfile in ```$MY_WEBAPP_REPO``` that uses the docker image from this repo. Below is a sample Docker file:
25
+
26
+ ```Dockerfile
27
+ FROM <--THe DOCKER IMAGE IN THIS REPO-->
28
+
29
+ RUN apt-get update && apt-get install -y python3 python3-pip
30
+ WORKDIR /code
31
+ COPY ./requirements.txt /code/requirements.txt
32
+ RUN pip install --no-cache-dir --upgrade pip
33
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
34
+
35
+ RUN useradd -m -u 1000 user
36
+ USER user
37
+ ENV HOME=/home/user \
38
+ PATH=/home/user/.local/bin:$PATH
39
+
40
+ WORKDIR $HOME/app
41
+ COPY --chown=user . $HOME/app
42
+
43
+ CMD ["python", "app.py"]
44
+ ```
45
+
46
+ The above docker file uses ```requirements.txt``` file in ```$MY_WEBAPP_REPO```. Create this ```requirements.txt``` file in ```$MY_WEBAPP_REPO``` with the required packages for your project. You can find a sample [requirements.txt](requirements.txt) in this repo or use ```pip freeze > my_requirements.txt``` to generate your requirements from your current project.
47
+
48
+ Create ```app.py``` file in ```$MY_WEBAPP_REPO``` with your application. For example you can use [Building your First Demo](https://www.gradio.app/guides/quickstart#building-your-first-demo) from the Gradio Quick Start Guide.
49
+
50
+ You can run your gradio app locally for testing:
51
+ ```
52
+ python app.py
53
+ ```
54
+
55
+ ### Build and run the docker image for your app
56
+
57
+ Building a docker image may be needed if you would like to host your app on a place like HuggingFace Spaces.
58
+
59
+ To use ```docker compose``` create ```compose.yaml``` file in ```$MY_WEBAPP_REPO```.
60
+
61
+ Alternatively one can use ```docker build``` and ```docker run`` commands. Consult docker documentation for the commands and their flags.
requirements.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ python-dotenv==0.21.*
2
+ transformers==4.37.*
3
+ gradio==4.16.*
4
+ gradio_client==0.8.*
5
+ torch==2.2.*
6
+ torchaudio==2.2.*
7
+ huggingface-hub==0.20.*
8
+ langchain==0.1.*
9
+ langchain-community==0.0.*
10
+ langchain-core==0.1.*
11
+ langchain-openai==0.0.*
12
+ langchainhub==0.1.*
13
+ langsmith==0.0.*
14
+ llama_cpp_python==0.2.*
15
+ openai==1.8.*