Files
Open-Assistant/docker/inference/Dockerfile.worker
T
Alan Jean fef871161c feat(inference): add Dockerfile for the inference stack's worker 🐋
Initial definition of the inference stack's worker container image.

Notes:
- The oasst-shared package is installed as root as a workaround: it seems
  that python 3.10+ doesn't pick up on a .egg-link file installed on the
  PYTHONPATH anywhere other than at a global site-package directory.
  This quirk is similar to the behaviour described here
  https://groups.google.com/g/python-virtualenv/c/sKVq_6gG5z4.

- pydantic 1.9.1 (specified by oasst-shared) is incompatible with python 3.11,
  and needs to be upgraded. For now, this image uses python 3.10, as
  specified by the .python-version file
2023-01-29 05:30:00 +04:00

67 lines
1.5 KiB
Docker

# syntax=docker/dockerfile:1
ARG MODULE="inference"
ARG SERVICE="worker"
ARG APP_USER="${MODULE}-${SERVICE}"
ARG APP_RELATIVE_PATH="${MODULE}/${SERVICE}"
FROM python:3.10-alpine3.17 as build
ARG APP_RELATIVE_PATH
WORKDIR /build
COPY ./${APP_RELATIVE_PATH}/requirements.txt .
RUN --mount=type=cache,target=/var/cache/pip \
pip install \
--cache-dir=/var/cache/pip \
--target=lib \
-r requirements.txt
FROM python:3.10-alpine3.17 as dev
ARG APP_USER
ARG APP_RELATIVE_PATH
ARG MODULE
ARG SERVICE
ENV APP_BASE="/opt/${MODULE}"
ENV APP_ROOT="${APP_BASE}/${SERVICE}"
ENV APP_LIBS="/var/opt/${APP_RELATIVE_PATH}/lib"
ENV SHARED_LIBS_BASE="${APP_BASE}/lib"
ENV PATH="${PATH}:${APP_LIBS}/bin"
ENV PYTHONPATH="${PYTHONPATH}:${APP_LIBS}"
RUN adduser \
--disabled-password \
--no-create-home \
"${APP_USER}"
WORKDIR ${APP_ROOT}
COPY --chown="${APP_USER}:${APP_USER}" ./oasst-shared ${SHARED_LIBS_BASE}/oasst-shared
RUN --mount=type=cache,target=/var/cache/pip,from=build \
pip install \
--cache-dir=/var/cache/pip \
-e "${SHARED_LIBS_BASE}/oasst-shared"
USER ${APP_USER}
COPY --chown="${APP_USER}:${APP_USER}" --from=build /build/lib ${APP_LIBS}
COPY --chown="${APP_USER}:${APP_USER}" ./${APP_RELATIVE_PATH}/__main__.py .
VOLUME [ "${APP_BASE}/lib/oasst-shared" ]
CMD python3 __main__.py --backend-url "${BACKEND_URL}" --inference-server-url "${INFERENCE_SERVER_URL}"