iamspruce commited on
Commit
d753114
·
1 Parent(s): 7ce3473

updated docker

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -21
Dockerfile CHANGED
@@ -1,35 +1,42 @@
 
1
  FROM python:3.10-slim
2
 
3
- # Set working directory inside the container
4
  WORKDIR /app
5
 
6
  # Install system dependencies
7
- # git is included for any potential future needs or if any dependency requires it for cloning
8
- # Install Java Runtime Environment (JRE) - crucial for language-tool-python
9
- RUN apt-get update && apt-get install -y git default-jre && rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
- # Install Python dependencies from requirements.txt
12
- # Ensure requirements.txt is copied before installing to leverage Docker cache
13
  COPY requirements.txt .
 
 
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
- # Download the spaCy English language model
17
- # This is crucial for resolving the "[E050] Can't find model 'en_core_web_sm'" error
18
  RUN python -m spacy download en_core_web_sm
19
 
20
- # Setup Hugging Face cache directory and permissions
21
- # This directory will now also be used by language-tool-python for its downloads.
22
- ENV HF_HOME=/cache
23
- RUN mkdir -p /cache && chmod -R 777 /cache
24
-
25
- # Set environment variable for language-tool-python download directory
26
- # This redirects LanguageTool's cache to the shared /cache directory
27
- ENV LANGUAGE_TOOL_DOWNLOAD_DIR=/cache
28
-
29
- # Copy the entire application code into the container
30
- # This copies your 'app' directory, including main.py, routers, models, etc.
31
  COPY app ./app
32
 
33
- # Command to run the FastAPI application using Uvicorn
34
- # Binds the app to all network interfaces (0.0.0.0) on port 7860
 
 
35
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use the official Python 3.10 slim image
2
  FROM python:3.10-slim
3
 
4
+ # Set the working directory inside the container
5
  WORKDIR /app
6
 
7
  # Install system dependencies
8
+ # - git (optional, useful if pip dependencies are installed via git)
9
+ # - default-jre is required for language_tool_python
10
+ RUN apt-get update && apt-get install -y \
11
+ git \
12
+ default-jre \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ # Set environment variables
16
+ # - HF_HOME: used by Hugging Face models
17
+ # - LANGUAGE_TOOL_DOWNLOAD_DIR: used by language_tool_python
18
+ # - HOME: so that ~/.cache resolves to a writable folder
19
+ ENV HF_HOME=/cache
20
+ ENV LANGUAGE_TOOL_DOWNLOAD_DIR=/cache
21
+ ENV HOME=/app
22
+
23
+ # Create and set permissions for cache directory
24
+ RUN mkdir -p /cache && chmod -R 777 /cache
25
 
26
+ # Copy Python dependency file
 
27
  COPY requirements.txt .
28
+
29
+ # Install Python dependencies
30
  RUN pip install --no-cache-dir -r requirements.txt
31
 
32
+ # Download spaCy English model
 
33
  RUN python -m spacy download en_core_web_sm
34
 
35
+ # Copy application code into the container
 
 
 
 
 
 
 
 
 
 
36
  COPY app ./app
37
 
38
+ # Expose the port (optional)
39
+ EXPOSE 7860
40
+
41
+ # Run the app using Uvicorn
42
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]