File size: 1,583 Bytes
20f2960
 
 
 
 
 
 
845ae1a
acf1663
 
845ae1a
a605a95
845ae1a
20f2960
 
 
 
 
 
 
 
 
a1fcc03
241829f
2c71ef2
615022a
 
 
9253c77
2c71ef2
 
241829f
 
 
20f2960
2ee7dcf
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
FROM python:3.12
# Create a new user named 'user' with user ID 1000 and create their home directory
RUN useradd -m -u 1000 user
# Switch to the newly created user
USER user
# Add the user's local bin directory to the PATH
ENV PATH="/home/user/.local/bin:$PATH"

# Pass the secret variable to the application
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true
RUN --mount=type=secret,id=PINECONE_API_KEY,mode=0444,required=true
RUN --mount=type=secret,id=OPENAI_API_KEY,mode=0444,required=true

# Set the working directory in the container to /app
WORKDIR /app
# Copy the requirements.txt file from the host to the container
# The --chown=user ensures the copied file is owned by our 'user'
COPY --chown=user ./requirements.txt requirements.txt
# Install the Python dependencies listed in requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the rest of the application code from the host to the container
# Again, ensure the copied files are owned by 'user'
COPY --chown=user . /app

# Make sure that you are copying the entire app directory into the container
# './app' specifies the source directory on your host machine.
# '/app' specifies the destination directory in the container. 
# After the command executes, all files from ./app on your host will be placed in /app inside the container.
COPY --chown=user ./app /app


# Add a debug command to check file location (remove this once verified)
RUN ls -l /app

# Specify the command to run when the container starts
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]