File size: 1,557 Bytes
5d63abc
47da386
 
 
 
 
afa36df
 
 
 
 
5d63abc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47da386
 
 
 
 
 
 
 
afa36df
 
 
 
5d63abc
 
290df04
1c6e0d5
52274a4
1c6e0d5
992e4ec
5d63abc
 
 
 
 
 
47da386
afa36df
47da386
1c6e0d5
 
47da386
5d63abc
1c6e0d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Use an official PyTorch image as a base
FROM pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime

# Set the working directory inside the container
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user
RUN useradd -m -u 1000 appuser

# Create cache directories and set permissions
RUN mkdir -p /.cache/huggingface && \
    mkdir -p /.cache/torch && \
    mkdir -p /.cache/sentence_transformers && \
    chown -R appuser:appuser /.cache && \
    chmod -R 777 /.cache

# Set environment variables for cache locations
ENV HF_HOME="/.cache/huggingface"
ENV TORCH_HOME="/.cache/torch"
ENV SENTENCE_TRANSFORMERS_HOME="/.cache/sentence_transformers"

# Install Python dependencies
RUN pip install --no-cache-dir \
    pandas \
    torch \
    sentence-transformers \
    transformers \
    numpy \
    faiss-cpu \
    fastapi \
    uvicorn[standard] \
    pydantic \
    python-multipart \
    huggingface_hub \
    accelerate>=0.26.0

# Copy the necessary files into the container
COPY plant_data_chunks_and_embeddings.csv /app/plant_data_chunks_and_embeddings.csv
COPY main.py /app/main.py

# Set proper permissions for the app directory
RUN chown -R appuser:appuser /app

# Switch to non-root user
USER appuser

# Set the environment variable to point to the app directory
ENV PYTHONPATH=/app

# Expose the port the app will run on
EXPOSE 5000

# Command to run the app using Uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"]