2024-05-25 08:10:59 +00:00
|
|
|
# Python 3.11
|
2024-06-08 00:27:57 +00:00
|
|
|
FROM python@sha256:ad26bf20080f6b43a7f10020201fb95a678445be9040c111e034d86dc0c80d71 as build
|
2024-05-25 08:10:59 +00:00
|
|
|
|
|
|
|
# Install OS dependencies
|
|
|
|
RUN apt-get update && apt-get install -y build-essential curl
|
|
|
|
|
|
|
|
# Set venv
|
|
|
|
ENV VIRTUAL_ENV=/opt/venv \
|
|
|
|
PATH="/opt/venv/bin:$PATH"
|
|
|
|
|
|
|
|
# Install uv
|
|
|
|
ADD https://astral.sh/uv/install.sh /install.sh
|
|
|
|
RUN chmod -R 655 /install.sh && /install.sh && rm /install.sh
|
|
|
|
|
|
|
|
# Create a virtual environment and install dependencies
|
|
|
|
COPY ./requirements.txt .
|
|
|
|
RUN /root/.cargo/bin/uv venv /opt/venv && \
|
|
|
|
/root/.cargo/bin/uv pip install --no-cache -r requirements.txt
|
|
|
|
|
|
|
|
# Python 3.11-slim-bookworm app image
|
2024-06-08 00:27:57 +00:00
|
|
|
FROM python@sha256:ad26bf20080f6b43a7f10020201fb95a678445be9040c111e034d86dc0c80d71
|
2024-05-25 08:10:59 +00:00
|
|
|
|
|
|
|
# Copy the virtual environment from the previous image
|
|
|
|
COPY --from=build /opt/venv /opt/venv
|
|
|
|
|
|
|
|
# Activate the virtual environment
|
|
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
|
|
|
|
# Set the working directory
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Copy the code
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
# Run the application
|
|
|
|
CMD ["python", "main.py"]
|