-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
54 lines (40 loc) · 1.31 KB
/
Dockerfile
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
44
45
46
47
48
49
50
51
52
53
54
# Use an official Python runtime as a parent image
FROM python:3.11-slim
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
&& rm -rf /var/lib/apt/lists/*
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
# Add Poetry to PATH
ENV PATH="${PATH}:/root/.local/bin"
# Configure Poetry
RUN poetry config virtualenvs.create false
# Copy only pyproject.toml and poetry.lock first
COPY pyproject.toml poetry.lock ./
# Install Python dependencies using Poetry
RUN poetry install --no-interaction --no-ansi
# Copy the rest of the application
COPY . .
# Create necessary directories
RUN mkdir -p uploads faiss_indexes
# Make ports available to the outside world
EXPOSE 8000 8501
# Create a script to load environment variables and run both FastAPI and Streamlit
RUN echo '#!/bin/bash\n\
set -a\n\
source .env\n\
set +a\n\
poetry run uvicorn main:app --host 0.0.0.0 --port 8000 &\n\
poetry run streamlit run app.py --server.port 8501 --server.address 0.0.0.0\n'\
> /app/start.sh
RUN chmod +x /app/start.sh
# Run the script when the container launches
CMD ["/app/start.sh"]