Update Dockerfile (#1056)
This commit is contained in:
42
Dockerfile
42
Dockerfile
@@ -1,27 +1,43 @@
|
|||||||
FROM python:3.11 as requirements-stage
|
# First stage for dependencies
|
||||||
|
FROM python:3.11-slim-bookworm AS base-stage
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
WORKDIR /tmp
|
# Install Poetry and export dependencies to requirements.txt in one layer
|
||||||
RUN pip install poetry
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
COPY ./pyproject.toml /tmp/pyproject.toml
|
curl \
|
||||||
COPY ./poetry.lock /tmp/poetry.lock
|
&& curl -sSL https://install.python-poetry.org | python3 - \
|
||||||
|
&& apt-get purge -y --auto-remove curl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& ln -s /root/.local/bin/poetry /usr/local/bin/poetry
|
||||||
|
|
||||||
|
# Copy dependency files first to leverage Docker cache
|
||||||
|
COPY ./pyproject.toml ./poetry.lock ./
|
||||||
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes
|
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes
|
||||||
|
|
||||||
FROM python:3.11-slim-bookworm
|
# Slim stage for final image
|
||||||
|
FROM python:3.11-slim-bookworm AS final-stage
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=requirements-stage /tmp/requirements.txt /app/requirements.txt
|
|
||||||
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
|
||||||
RUN playwright install-deps
|
|
||||||
RUN playwright install
|
|
||||||
RUN apt-get install -y xauth x11-apps netpbm && apt-get clean
|
|
||||||
|
|
||||||
|
# Copy and install dependencies in one layer to reduce image size
|
||||||
|
COPY --from=base-stage /app/requirements.txt /app/requirements.txt
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
xauth x11-apps netpbm \
|
||||||
|
&& pip install --no-cache-dir -r requirements.txt \
|
||||||
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install Playwright dependencies and browser binaries in a single layer
|
||||||
|
RUN pip install --no-cache-dir playwright && playwright install-deps && playwright install
|
||||||
|
|
||||||
|
# Copy the application code and set environment variables
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
ENV PYTHONPATH="/app:$PYTHONPATH"
|
ENV PYTHONPATH="/app:$PYTHONPATH"
|
||||||
ENV VIDEO_PATH=/data/videos
|
ENV VIDEO_PATH=/data/videos
|
||||||
ENV HAR_PATH=/data/har
|
ENV HAR_PATH=/data/har
|
||||||
ENV ARTIFACT_STORAGE_PATH=/data/artifacts
|
ENV ARTIFACT_STORAGE_PATH=/data/artifacts
|
||||||
|
|
||||||
|
# Copy and set entrypoint script permissions in a single layer
|
||||||
COPY ./entrypoint-skyvern.sh /app/entrypoint-skyvern.sh
|
COPY ./entrypoint-skyvern.sh /app/entrypoint-skyvern.sh
|
||||||
RUN chmod +x /app/entrypoint-skyvern.sh
|
RUN chmod +x /app/entrypoint-skyvern.sh
|
||||||
|
|
||||||
CMD [ "/bin/bash", "/app/entrypoint-skyvern.sh" ]
|
# Set the entrypoint
|
||||||
|
ENTRYPOINT [ "/app/entrypoint-skyvern.sh" ]
|
||||||
|
|||||||
Reference in New Issue
Block a user