1
+ # syntax=docker/dockerfile:1
1
2
# Use an official Python runtime as a parent image
2
- FROM python:3.11.7
3
+ FROM python:3.11.7 as base
3
4
4
5
# Set the working directory in the Docker image
5
6
WORKDIR /usr/src/app
6
7
7
- # Create the requirements directory
8
- RUN mkdir requirements
8
+ # Copy the entire app directory into the container at /usr/src/app
9
+ COPY app/requirements/requirements.txt /usr/src/app
10
+ # use trailing . to include hidden files
11
+ COPY app/. /usr/src/app
9
12
10
- # Copy requirements.txt into the container at /usr/src/app/requirements/
11
- COPY requirements/requirements.txt requirements/
13
+ # Create and activate a virtual environment
14
+ RUN python -m venv venv
12
15
13
- # Install dependencies
14
- RUN pip install --no-cache-dir -r requirements/requirements.txt
15
-
16
- # Copy the .env file into the container at /usr/src/app
17
- COPY .env .
18
- # Copy the rest of the app directory contents into the container at /usr/src/app
19
- COPY . .
16
+ # Activate the virtual environment and install dependencies
17
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
20
18
21
19
# Make port 8000 available to the world outside this container
22
20
EXPOSE 8000
@@ -28,8 +26,5 @@ HEALTHCHECK --interval=5m --timeout=3s \
28
26
--start-period=1m \
29
27
CMD curl --fail http://localhost:8000/docs || exit 1
30
28
31
- # Run main.py when the container launches
32
- CMD ["python" , "main.py" , "--host" , "0.0.0.0" , "--port" , "8000" ]
33
-
34
- ENV APP_MODULE=main
35
- ENV MARVIN_OPENAI_CHAT_COMPLETIONS_MODEL=gpt-3.5-turbo
29
+ # Set entrypoint for FastAPI when the container launches
30
+ ENTRYPOINT ["python" , "main.py" ]
0 commit comments