forked from btrantruong/osome-csdl-ranking-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-ranker
60 lines (47 loc) · 2.05 KB
/
Dockerfile-ranker
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
55
56
57
58
59
60
# Builder stage
# =============
# Use the standard python image for building
FROM python:3.12 as builder
ENV PIP_REQUESTS_TIMEOUT=300 \
POETRY_REQUESTS_TIMEOUT=300 \
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 ./
# Install dependencies from lock file but not the package itself (--no-root),
# which is installed later. Separating this step from the package installation
# allows to take advantange of docker's caching system for repeated builds.
# For extra robustness, we also include --no-directory to skip installing any
# dependency that is specified as a path to a local directory
# (https://python-poetry.org/docs/dependency-specification/#path-dependencies)
# as these should be copied directly along with the package in the next step.
# Note we also clear the poetry cache to keep the overall image size low.
RUN pip install poetry \
&& poetry install --only=main --no-root --no-directory \
&& rm -rf ${POETRY_CACHE_DIR}
# Build a wheel for package and install it into the virtual environment using
# pip. This is preferred as it actually installs the package as opposed to
# copying the source code into /app. Lastly, if there is any library specified
# as a path dependency we should copy those too here.
COPY pyproject.toml poetry.lock README.md ./
COPY dante ./dante
RUN poetry build --format=wheel \
&& poetry run pip install --no-deps dist/*.whl \
&& rm -rf dist
# Runtime stage
# =============
# Use the python slim image (produces smaller images)
FROM python:3.12-slim as runtime
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:${PATH}" \
DANTE_CACHE_DIR=/app/cache \
DANTE_CONFIG_PATH="/app/config.ini" \
DANTE_LOG_DIR=/app/logs
WORKDIR /app
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
# # Expose the port the app runs on
EXPOSE 8000
# Define the command to run the application
CMD ["uvicorn", "--host", "0.0.0.0", "--port", "8000", "dante.app.ranking_server.ranking_server:app"]