File size: 982 Bytes
49ecd5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use an official Python runtime as the base image
FROM python:3.10.9

# Set the working directory to /app (root for your code inside the container)
WORKDIR /app

# Copy the requirements file into the container
COPY requirements.txt /app/

# Install dependencies in a virtual environment
RUN python3 -m venv /venv \
    && /venv/bin/pip install --upgrade pip \
    && /venv/bin/pip install -r /app/requirements.txt

# Copy the rest of your application code into the container
COPY . /app/

# Set the environment variable for the virtual environment
ENV PATH="/venv/bin:$PATH"

# Expose the port that your app will run on
EXPOSE 7860

# Create a non-root user and switch to that user to avoid running as root
RUN useradd -m myuser

# Give the non-root user permission to write to the Datasets/Weights directory
RUN chown -R myuser:myuser /app/Datasets

# Switch to the non-root user
USER myuser

# Run the Python script when the container starts
CMD ["python3", "Model_API/main.py"]