theaniketgiri commited on
Commit
df9f554
·
1 Parent(s): b1d7b15
Files changed (2) hide show
  1. Dockerfile +21 -8
  2. README.md +9 -8
Dockerfile CHANGED
@@ -9,22 +9,35 @@ RUN apt-get update && apt-get install -y \
9
  build-essential \
10
  && rm -rf /var/lib/apt/lists/*
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  # Copy requirements first to leverage Docker cache
13
  COPY requirements.txt .
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
  # Copy the rest of the application
17
- COPY . .
18
 
19
  # Create necessary directories
20
- RUN mkdir -p src/web
 
21
 
22
- # Expose the port
23
- EXPOSE 8000
24
 
25
- # Set environment variables
26
- ENV PYTHONPATH=/app
27
- ENV PORT=8000
28
 
29
- # Command to run the application
30
  CMD ["uvicorn", "src.api.app:app", "--host", "0.0.0.0", "--port", "8000"]
 
9
  build-essential \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Create a non-root user
13
+ RUN useradd -m -u 1000 user
14
+
15
+ # Create cache directory with proper permissions
16
+ RUN mkdir -p /home/user/.cache/huggingface && \
17
+ chown -R user:user /home/user/.cache
18
+
19
+ # Set environment variables
20
+ ENV PYTHONPATH=/app
21
+ ENV PORT=8000
22
+ ENV TRANSFORMERS_CACHE=/home/user/.cache/huggingface
23
+ ENV HF_HOME=/home/user/.cache/huggingface
24
+
25
  # Copy requirements first to leverage Docker cache
26
  COPY requirements.txt .
27
  RUN pip install --no-cache-dir -r requirements.txt
28
 
29
  # Copy the rest of the application
30
+ COPY --chown=user:user . .
31
 
32
  # Create necessary directories
33
+ RUN mkdir -p src/web && \
34
+ chown -R user:user /app
35
 
36
+ # Switch to non-root user
37
+ USER user
38
 
39
+ # Expose the FastAPI port
40
+ EXPOSE 8000
 
41
 
42
+ # Command to run the FastAPI application
43
  CMD ["uvicorn", "src.api.app:app", "--host", "0.0.0.0", "--port", "8000"]
README.md CHANGED
@@ -4,9 +4,11 @@ emoji: 🚀
4
  colorFrom: red
5
  colorTo: red
6
  sdk: docker
7
- app_port: 8501
8
  tags:
9
- - streamlit
 
 
10
  pinned: false
11
  ---
12
 
@@ -14,6 +16,8 @@ pinned: false
14
 
15
  A synthetic medical text generator that creates realistic medical records using AI models. The application provides both a FastAPI backend and a Streamlit interface.
16
 
 
 
17
  ## Features
18
 
19
  - Generate various types of medical records:
@@ -26,8 +30,8 @@ A synthetic medical text generator that creates realistic medical records using
26
  - Hugging Face models (default)
27
  - Google Gemini (optional)
28
  - Two interfaces:
29
- - FastAPI with HTML frontend
30
- - Streamlit interface
31
 
32
  ## API Endpoints
33
 
@@ -76,10 +80,7 @@ A synthetic medical text generator that creates realistic medical records using
76
 
77
  ### Hugging Face Spaces Deployment
78
 
79
- 1. Create a new Space on Hugging Face
80
- 2. Choose "Docker" as the SDK
81
- 3. Push this repository to your Space
82
- 4. The application will be automatically deployed
83
 
84
  ## Environment Variables
85
 
 
4
  colorFrom: red
5
  colorTo: red
6
  sdk: docker
7
+ app_port: 8000
8
  tags:
9
+ - fastapi
10
+ - medical
11
+ - ai
12
  pinned: false
13
  ---
14
 
 
16
 
17
  A synthetic medical text generator that creates realistic medical records using AI models. The application provides both a FastAPI backend and a Streamlit interface.
18
 
19
+ > **Note**: This Hugging Face Space runs the FastAPI version with HTML interface. For the Streamlit version, please run locally using `streamlit run app.py`.
20
+
21
  ## Features
22
 
23
  - Generate various types of medical records:
 
30
  - Hugging Face models (default)
31
  - Google Gemini (optional)
32
  - Two interfaces:
33
+ - FastAPI with HTML frontend (Hugging Face Space)
34
+ - Streamlit interface (Local development)
35
 
36
  ## API Endpoints
37
 
 
80
 
81
  ### Hugging Face Spaces Deployment
82
 
83
+ This Space runs the FastAPI version with HTML interface. The application is automatically deployed when you push to the repository.
 
 
 
84
 
85
  ## Environment Variables
86