Spaces:
Paused
Paused
| # The builder image, used to build the virtual environment | |
| FROM python:3.11-buster as builder | |
| RUN pip install poetry==1.4.2 | |
| ENV POETRY_NO_INTERACTION=1 \ | |
| POETRY_VIRTUALENVS_IN_PROJECT=1 \ | |
| POETRY_VIRTUALENVS_CREATE=1 \ | |
| POETRY_CACHE_DIR=/tmp/poetry_cache | |
| WORKDIR /app | |
| COPY pyproject.toml poetry.lock ./ | |
| RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev --no-root | |
| # The runtime image, used to just run the code provided its virtual environment | |
| FROM python:3.11-slim-buster as runtime | |
| # Get secret DB_URL and output it to /test at buildtime | |
| RUN --mount=type=secret,id=DB_URL,mode=0444,required=true \ | |
| cat /run/secrets/DB_URL > /test | |
| ENV VIRTUAL_ENV=/app/.venv \ | |
| PATH="/app/.venv/bin:$PATH" | |
| COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} | |
| WORKDIR /app | |
| COPY image_search /app/image_search | |
| COPY static /app/static | |
| COPY images /app/images | |
| CMD ["uvicorn", "image_search.main:app", "--host", "0.0.0.0", "--port", "7860"] | |