File size: 1,053 Bytes
a140fe2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c610d8c
 
 
7792573
a140fe2
 
 
 
 
 
 
 
 
 
 
 
3b5e946
a140fe2
46d6dc6
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
# Use the official Python image as the base image
FROM python:3.10

# Set the working directory in the container
WORKDIR /app

# Create a non-root user
RUN useradd -ms /bin/bash myuser

# Give the user ownership of the working directory and home directory
RUN chown -R myuser:myuser /app /home/myuser

# Switch to the non-root user
USER myuser

# Copy the entire contents of the local directory into the container
COPY . .

# Expose the secret HUGGINGFACE_TOKEN at buildtime and use its value as the Hugging Face token
RUN --mount=type=secret,id=HUGGINGFACE_TOKEN,mode=0444,required=true \
    echo "HUGGINGFACE_TOKEN=$(cat /run/secrets/HUGGINGFACE_TOKEN)" > .env

# Install chainlit and add it to PATH
RUN pip install chainlit --user

# Set the PATH to include user-specific binaries
ENV PATH="/home/myuser/.local/bin:${PATH}"

# Install the required Python packages
RUN pip install -r requirements.txt

# Expose port 7860 internally in the container
EXPOSE 7860

# Run the ChainLit command
CMD ["chainlit", "run", "model.py", "-w", "--port", "7860"]