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

updated docker

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -28
Dockerfile CHANGED
@@ -1,42 +1,40 @@
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"]
 
 
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 also be used by language-tool-python for its main downloads.
22
+ ENV HF_HOME=/cache
23
+ RUN mkdir -p /cache && chmod -R 777 /cache
24
+
25
+ # Explicitly create and set permissions for /.cache
26
+ # This is to address PermissionError: [Errno 13] Permission denied: '/.cache'
27
+ # which language-tool-python might be trying to write to.
28
+ RUN mkdir -p /.cache && chmod -R 777 /.cache
29
 
30
+ # Set environment variable for language-tool-python download directory
31
+ # This redirects LanguageTool's primary downloads to the shared /cache directory.
32
+ ENV LANGUAGE_TOOL_DOWNLOAD_DIR=/cache
33
+
34
+ # Copy the entire application code into the container
35
+ # This copies your 'app' directory, including main.py, routers, models, etc.
36
+ COPY app ./app
37
 
38
+ # Command to run the FastAPI application using Uvicorn
39
+ # Binds the app to all network interfaces (0.0.0.0) on port 7860
40
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]