File size: 1,091 Bytes
a6afebb
 
 
 
 
 
 
 
 
9bdbe34
57c32c7
9bdbe34
 
 
 
 
 
 
 
 
 
 
 
 
 
a6afebb
 
5f7bb6e
a6afebb
9bdbe34
a6afebb
 
9bdbe34
 
a6afebb
18e9486
 
 
9bdbe34
57c32c7
 
9bdbe34
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
# Use a lightweight base image with Python
FROM python:3.9-slim

# Install git and git-lfs for cloning large models
RUN apt-get update && apt-get install -y git git-lfs

# Initialize git-lfs
RUN git-lfs install

# Create a non-root user and set up environment variables
RUN useradd -m -u 1000 user

# Set environment variables
ENV HOME=/home/user \
    TRANSFORMERS_CACHE=/home/user/.cache \
    PATH=/home/user/.local/bin:$PATH

# Switch to the newly created user
USER user

# Set the working directory inside the container
WORKDIR $HOME/app

# Copy the requirements file
COPY --chown=user:user requirements.txt .

# Clone the Hugging Face model repository (replace with the desired model URL)
RUN git clone https://huggingface.co/matsant01/STEMerald-2b $HOME/app/model

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application code and set file ownership
COPY --chown=user:user . .

# Copy the FastAPI app
COPY app.py .

# Expose the port and run the app with Uvicorn 
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]