hequ commited on
Commit
a4dd17d
·
verified ·
1 Parent(s): 84aa437

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +41 -0
Dockerfile ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dockerfile for uni-api deployment on Hugging Face Spaces
2
+
3
+ # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
4
+ # you will also find guides on how best to write your Dockerfile
5
+
6
+ # 1. Base Image
7
+ FROM python:3.9
8
+
9
+ # 2. Create a non-root user for security
10
+ RUN useradd -m -u 1000 user
11
+ USER user
12
+ # Add user's local bin to PATH (for packages installed with pip install --user)
13
+ ENV PATH="/home/user/.local/bin:$PATH"
14
+
15
+ # 3. Set the working directory
16
+ WORKDIR /app
17
+
18
+ # 4. Clone the application code from GitHub, including submodules
19
+ # IMPORTANT: Replace 'main' with the correct branch name if it's different!
20
+ # Use --recurse-submodules to fetch the 'core' submodule content
21
+ RUN git clone --branch main --recurse-submodules https://github.com/yym68686/uni-api.git .
22
+
23
+ # 5. Install Python dependencies
24
+ # Assumes requirements.txt is present in the cloned repository root
25
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
26
+
27
+ # 6. Copy necessary files from the build context (local or HF repo root)
28
+ # Copy the API template and the entrypoint script into the image
29
+ COPY --chown=user ./api.template.yaml /app/api.template.yaml
30
+ COPY --chown=user ./entrypoint.sh /app/entrypoint.sh
31
+
32
+ # 7. Make the entrypoint script executable
33
+ RUN chmod +x /app/entrypoint.sh
34
+
35
+ # 8. Set the entrypoint script to run on container start
36
+ # This script will generate the final api.yaml using secrets/environment variables
37
+ ENTRYPOINT ["/app/entrypoint.sh"]
38
+
39
+ # 9. Define the default command to run the application
40
+ # This command will be executed by the entrypoint script (passed as "$@")
41
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]