Skip to content

Commit 765f255

Browse files
authored
Remove relocatable venvs (#154)
1 parent 434e246 commit 765f255

File tree

24 files changed

+138
-177
lines changed

24 files changed

+138
-177
lines changed

interactive_ai/migration_job/Dockerfile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ ENV UV_LINK_MODE=copy
99
ENV UV_PYTHON_DOWNLOADS=0
1010

1111
# Copy the service dependencies
12-
WORKDIR /builder
1312
COPY --link --from=libs . libs
1413
COPY --link --from=data_migration . interactive_ai/data_migration
1514

16-
WORKDIR /builder/interactive_ai/migration_job
15+
WORKDIR /interactive_ai/migration_job
1716

1817
COPY --link --from=ghcr.io/astral-sh/uv:0.6.12 /uv /bin/uv
1918

@@ -22,7 +21,6 @@ COPY --link migration_job/ .
2221
RUN --mount=type=cache,target=/root/.cache/uv \
2322
--mount=type=bind,source=uv.lock,target=uv.lock \
2423
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
25-
uv venv --relocatable && \
2624
uv sync --frozen --no-dev --no-editable
2725

2826
FROM base AS runtime
@@ -34,14 +32,14 @@ RUN apt-get update && \
3432
useradd -l -u 10001 non-root && \
3533
pip3 uninstall -y setuptools pip wheel && \
3634
rm -rf /root/.cache/pip
37-
38-
COPY --link --from=build --chown=10001 /builder/interactive_ai/migration_job /app/migration_job
3935

40-
ARG VENV="/app/migration_job/.venv"
36+
COPY --link --from=build --chown=10001 /interactive_ai/migration_job /interactive_ai/migration_job
37+
38+
ARG VENV="/interactive_ai/migration_job/.venv"
4139
ENV PATH="$VENV/bin:$PATH"
42-
ENV PYTHONPATH="/app"
40+
ENV PYTHONPATH="/interactive_ai"
4341

4442
USER non-root
45-
WORKDIR /app
46-
COPY --link --chown=10001 entrypoint.sh .
43+
WORKDIR /interactive_ai/migration_job
44+
COPY --link --chown=10001 entrypoint.sh /interactive_ai/migration_job
4745
ENTRYPOINT [ "./entrypoint.sh"]

interactive_ai/services/auto_train/Dockerfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ARG OTX_RELEASE_TAG=2.4.2
77

88
RUN apt-get update && \
99
apt-get install -y --no-install-recommends \
10-
git
10+
git
1111

1212
RUN git clone --branch $OTX_RELEASE_TAG --single-branch https://github.com/open-edge-platform/training_extensions.git
1313

@@ -18,11 +18,10 @@ ENV UV_LINK_MODE=copy
1818
ENV UV_PYTHON_DOWNLOADS=0
1919

2020
# Copy the service dependencies
21-
WORKDIR /builder
2221
COPY --link --from=libs . libs
2322
COPY --link --from=iai_core . interactive_ai/libs/iai_core_py
2423

25-
WORKDIR /builder/interactive_ai/services/auto_train
24+
WORKDIR /interactive_ai/services/auto_train
2625

2726
COPY --link --from=ghcr.io/astral-sh/uv:0.6.12 /uv /bin/uv
2827

@@ -31,7 +30,6 @@ COPY --link app/ .
3130
RUN --mount=type=cache,target=/root/.cache/uv \
3231
--mount=type=bind,source=uv.lock,target=uv.lock \
3332
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
34-
uv venv --relocatable && \
3533
uv sync --frozen --no-dev --no-editable
3634

3735
FROM base AS runtime
@@ -41,13 +39,13 @@ RUN useradd -l -u 10001 non-root && \
4139
rm -rf /root/.cache/pip
4240

4341
# Copy the application from the builder
44-
COPY --link --from=build --chown=10001 /builder/interactive_ai/services/auto_train /app
42+
COPY --link --from=build --chown=10001 /interactive_ai/services/auto_train /interactive_ai/services/auto_train
4543
COPY --link --from=build --chown=10001 /training_extensions/src/otx/tools/templates /model_templates
4644

4745
# Place executables in the environment at the front of the path
48-
ENV PATH="/app/.venv/bin:$PATH"
49-
ENV PYTHONPATH="/app"
46+
ENV PATH="/interactive_ai/services/auto_train/.venv/bin:$PATH"
47+
ENV PYTHONPATH="/interactive_ai/services/auto_train"
5048

5149
USER non-root
52-
WORKDIR /app
50+
WORKDIR /interactive_ai/services/auto_train
5351
CMD ["python", "main.py"]

interactive_ai/services/dataset_ie/Dockerfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ ENV UV_LINK_MODE=copy
99
ENV UV_PYTHON_DOWNLOADS=0
1010

1111
# Copy the service dependencies
12-
WORKDIR /builder
1312
COPY --link --from=libs . libs
1413
COPY --link --from=iai_core . interactive_ai/libs/iai_core_py
1514

16-
WORKDIR /builder/interactive_ai/services/dataset_ie
15+
WORKDIR /interactive_ai/services/dataset_ie
1716

1817
COPY --link --from=ghcr.io/astral-sh/uv:0.6.12 /uv /bin/uv
1918

@@ -22,7 +21,6 @@ COPY --link app/ .
2221
RUN --mount=type=cache,target=/root/.cache/uv \
2322
--mount=type=bind,source=uv.lock,target=uv.lock \
2423
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
25-
uv venv --relocatable && \
2624
uv sync --frozen --no-dev --no-editable
2725

2826
FROM base AS runtime
@@ -32,12 +30,12 @@ RUN useradd -l -u 10001 non-root && \
3230
rm -rf /root/.cache/pip
3331

3432
# Copy the application from the builder
35-
COPY --link --from=build --chown=10001 /builder/interactive_ai/services/dataset_ie /app
33+
COPY --link --from=build --chown=10001 /interactive_ai/services/dataset_ie /interactive_ai/services/dataset_ie
3634

3735
# Place executables in the environment at the front of the path
38-
ENV PATH="/app/.venv/bin:$PATH"
39-
ENV PYTHONPATH="/app"
36+
ENV PATH="/interactive_ai/services/dataset_ie/.venv/bin:$PATH"
37+
ENV PYTHONPATH="/interactive_ai/services/dataset_ie"
4038

4139
USER non-root
42-
WORKDIR /app/communication/endpoints
40+
WORKDIR /interactive_ai/services/dataset_ie/communication/endpoints
4341
CMD ["python", "main.py"]

interactive_ai/services/director/Dockerfile

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ARG OTX_RELEASE_TAG=2.4.2
77

88
RUN apt-get update && \
99
apt-get install -y --no-install-recommends \
10-
git
10+
git
1111

1212
RUN git clone --branch $OTX_RELEASE_TAG --single-branch https://github.com/open-edge-platform/training_extensions.git
1313

@@ -18,21 +18,19 @@ ENV UV_LINK_MODE=copy
1818
ENV UV_PYTHON_DOWNLOADS=0
1919

2020
# Copy the service dependencies
21-
WORKDIR /builder
2221
COPY --link --from=libs . libs
2322
COPY --link --from=iai_core . interactive_ai/libs/iai_core_py
2423
COPY --link --from=supported_models . interactive_ai/supported_models
2524

26-
WORKDIR /builder/interactive_ai/services/director
25+
WORKDIR /interactive_ai/services/director
2726

2827
COPY --link --from=ghcr.io/astral-sh/uv:0.6.12 /uv /bin/uv
2928

30-
COPY --link app/ .
29+
COPY --link app/ app
3130

3231
RUN --mount=type=cache,target=/root/.cache/uv \
3332
--mount=type=bind,source=uv.lock,target=uv.lock \
3433
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
35-
uv venv --relocatable && \
3634
uv sync --frozen --no-dev --no-editable
3735

3836
FROM base AS runtime
@@ -42,14 +40,14 @@ RUN useradd -l -u 10001 non-root && \
4240
rm -rf /root/.cache/pip
4341

4442
# Copy the application from the builder
45-
COPY --link --from=build --chown=10001 /builder/interactive_ai/services/director /app
43+
COPY --link --from=build --chown=10001 /interactive_ai/services/director /interactive_ai/services/director
4644
COPY --link --from=build --chown=10001 /training_extensions/src/otx/tools/templates /model_templates
47-
COPY --link --from=schemas . /api
45+
COPY --link --from=schemas . /interactive_ai/services/api
4846

4947
# Place executables in the environment at the front of the path
50-
ENV PATH="/app/.venv/bin:$PATH"
51-
ENV PYTHONPATH="/app"
48+
ENV PATH="/interactive_ai/services/director/.venv/bin:$PATH"
49+
ENV PYTHONPATH="/interactive_ai/services/director:/interactive_ai/services/director/app"
5250

5351
USER non-root
54-
WORKDIR /app/communication
52+
WORKDIR /interactive_ai/services/director/app/communication
5553
CMD ["python", "main.py"]

interactive_ai/services/jobs/Dockerfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ ENV UV_LINK_MODE=copy
99
ENV UV_PYTHON_DOWNLOADS=0
1010

1111
# Copy the service dependencies
12-
WORKDIR /builder
1312
COPY --link --from=libs . libs
1413
COPY --link --from=iai_core . interactive_ai/libs/iai_core_py
1514

16-
WORKDIR /builder/interactive_ai/services/jobs
15+
WORKDIR /interactive_ai/services/jobs
1716

1817
COPY --link --from=ghcr.io/astral-sh/uv:0.6.12 /uv /bin/uv
1918

@@ -22,7 +21,6 @@ COPY --link app/ .
2221
RUN --mount=type=cache,target=/root/.cache/uv \
2322
--mount=type=bind,source=uv.lock,target=uv.lock \
2423
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
25-
uv venv --relocatable && \
2624
uv sync --frozen --no-dev --no-editable
2725

2826
FROM base AS runtime
@@ -32,12 +30,12 @@ RUN useradd -l -u 10001 non-root && \
3230
rm -rf /root/.cache/pip
3331

3432
# Copy the application from the builder
35-
COPY --link --from=build --chown=10001 /builder/interactive_ai/services/jobs /app
33+
COPY --link --from=build --chown=10001 /interactive_ai/services/jobs /interactive_ai/services/jobs
3634

3735
# Place executables in the environment at the front of the path
38-
ENV PATH="/app/.venv/bin:$PATH"
39-
ENV PYTHONPATH="/app"
36+
ENV PATH="/interactive_ai/services/jobs/.venv/bin:$PATH"
37+
ENV PYTHONPATH="/interactive_ai/services/jobs"
4038

4139
USER non-root
42-
WORKDIR /app
40+
WORKDIR /interactive_ai/services/jobs
4341
CMD ["python", "microservice/rest/main.py"]

interactive_ai/services/mlflow_geti_store/Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ENV UV_LINK_MODE=copy
88
# Disable Python downloads, because we want to use the system interpreter across both images.
99
ENV UV_PYTHON_DOWNLOADS=0
1010

11-
WORKDIR /builder/interactive_ai/services/mlflow_geti_store
11+
WORKDIR /interactive_ai/services/mlflow_geti_store
1212

1313
COPY --link --from=ghcr.io/astral-sh/uv:0.6.12 /uv /bin/uv
1414

@@ -18,7 +18,6 @@ COPY --link entrypoints/ /entrypoints
1818
RUN --mount=type=cache,target=/root/.cache/uv \
1919
--mount=type=bind,source=uv.lock,target=uv.lock \
2020
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
21-
uv venv --relocatable && \
2221
uv sync --frozen --no-dev --no-editable
2322

2423

@@ -28,14 +27,14 @@ RUN useradd -l -u 10001 non-root && \
2827
pip3 uninstall -y setuptools pip wheel && \
2928
rm -rf /root/.cache/pip
3029

31-
COPY --link --from=build --chown=10001 /builder/interactive_ai/services/mlflow_geti_store /app/mlflow_geti_store
30+
COPY --link --from=build --chown=10001 /interactive_ai/services/mlflow_geti_store /interactive_ai/services/mlflow_geti_store
3231

33-
ARG VENV="/app/mlflow_geti_store/.venv"
32+
ARG VENV="/interactive_ai/services/mlflow_geti_store/.venv"
3433
ENV PATH="$VENV/bin:$PATH"
35-
ENV PYTHONPATH="/app"
34+
ENV PYTHONPATH="/interactive_ai/services"
3635

3736
USER non-root
38-
WORKDIR /app
37+
WORKDIR /interactive_ai/services/mlflow_geti_store
3938
COPY --link --from=build --chown=10001 entrypoints/. .
4039

4140
COPY --chown=10001 --chmod=500 /entrypoints/check_liveliness ${VENV}/bin/

interactive_ai/services/model_registration/Dockerfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ ENV UV_LINK_MODE=copy
99
ENV UV_PYTHON_DOWNLOADS=0
1010

1111
# Copy the service dependencies
12-
WORKDIR /builder
1312
COPY --link --from=libs . libs
1413

15-
WORKDIR /builder/interactive_ai/services/model_registration
14+
WORKDIR /interactive_ai/services/model_registration
1615

1716
COPY --link --from=ghcr.io/astral-sh/uv:0.6.12 /uv /bin/uv
1817

@@ -21,7 +20,6 @@ COPY --link app/ .
2120
RUN --mount=type=cache,target=/root/.cache/uv \
2221
--mount=type=bind,source=uv.lock,target=uv.lock \
2322
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
24-
uv venv --relocatable && \
2523
uv sync --frozen --no-dev --no-editable
2624

2725
FROM base AS runtime
@@ -37,12 +35,12 @@ RUN apt-get update && \
3735
rm -rf /root/.cache/pip
3836

3937
# Copy the application from the builder
40-
COPY --link --from=build --chown=10001 /builder/interactive_ai/services/model_registration /app
38+
COPY --link --from=build --chown=10001 /interactive_ai/services/model_registration /interactive_ai/services/model_registration
4139

4240
# Place executables in the environment at the front of the path
43-
ENV PATH="/app/.venv/bin:$PATH"
44-
ENV PYTHONPATH="/app"
41+
ENV PATH="/interactive_ai/services/model_registration/.venv/bin:$PATH"
42+
ENV PYTHONPATH="/interactive_ai/services/model_registration"
4543

4644
USER non-root
47-
WORKDIR /app
45+
WORKDIR /interactive_ai/services/model_registration
4846
CMD ["python", "main.py"]

interactive_ai/services/project_ie/Dockerfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ ENV UV_LINK_MODE=copy
99
ENV UV_PYTHON_DOWNLOADS=0
1010

1111
# Copy the service dependencies
12-
WORKDIR /builder
1312
COPY --link --from=libs . libs
1413
COPY --link --from=iai_core . interactive_ai/libs/iai_core_py
1514

16-
WORKDIR /builder/interactive_ai/services/project_ie
15+
WORKDIR /interactive_ai/services/project_ie
1716

1817
COPY --link --from=ghcr.io/astral-sh/uv:0.6.12 /uv /bin/uv
1918

@@ -22,7 +21,6 @@ COPY --link app/ .
2221
RUN --mount=type=cache,target=/root/.cache/uv \
2322
--mount=type=bind,source=uv.lock,target=uv.lock \
2423
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
25-
uv venv --relocatable && \
2624
uv sync --frozen --no-dev --no-editable
2725

2826
FROM base AS runtime
@@ -32,12 +30,12 @@ RUN useradd -l -u 10001 non-root && \
3230
rm -rf /root/.cache/pip
3331

3432
# Copy the application from the builder
35-
COPY --link --from=build --chown=10001 /builder/interactive_ai/services/project_ie /app
33+
COPY --link --from=build --chown=10001 /interactive_ai/services/project_ie /interactive_ai/services/project_ie
3634

3735
# Place executables in the environment at the front of the path
38-
ENV PATH="/app/.venv/bin:$PATH"
39-
ENV PYTHONPATH="/app"
36+
ENV PATH="/interactive_ai/services/project_ie/.venv/bin:$PATH"
37+
ENV PYTHONPATH="/interactive_ai/services/project_ie"
4038

4139
USER non-root
42-
WORKDIR /app/communication/endpoints
40+
WORKDIR /interactive_ai/services/project_ie/communication/endpoints
4341
CMD ["python", "main.py"]

interactive_ai/services/resource/Dockerfile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,19 @@ ENV UV_LINK_MODE=copy
1818
ENV UV_PYTHON_DOWNLOADS=0
1919

2020
# Copy the service dependencies
21-
WORKDIR /builder
2221
COPY --link --from=libs . libs
2322
COPY --link --from=iai_core . interactive_ai/libs/iai_core_py
2423
COPY --link --from=media_utils . interactive_ai/libs/media_utils
2524

26-
WORKDIR /builder/interactive_ai/services/resource
25+
WORKDIR /interactive_ai/services/resource
2726

2827
COPY --link --from=ghcr.io/astral-sh/uv:0.6.12 /uv /bin/uv
2928

30-
COPY --link app/ .
29+
COPY --link app/ app
3130

3231
RUN --mount=type=cache,target=/root/.cache/uv \
3332
--mount=type=bind,source=uv.lock,target=uv.lock \
3433
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
35-
uv venv --relocatable && \
3634
uv sync --frozen --no-dev --no-editable
3735

3836
FROM base AS runtime
@@ -46,14 +44,14 @@ RUN apt-get update && \
4644
rm -rf /root/.cache/pip
4745

4846
# Copy the application from the builder
49-
COPY --link --from=build --chown=10001 /builder/interactive_ai/services/resource /app
47+
COPY --link --from=build --chown=10001 /interactive_ai/services/resource /interactive_ai/services/resource
5048
COPY --link --from=build --chown=10001 /training_extensions/src/otx/tools/templates /model_templates
51-
COPY --link --from=schemas . /api
49+
COPY --link --from=schemas . /interactive_ai/services/api
5250

5351
# Place executables in the environment at the front of the path
54-
ENV PATH="/app/.venv/bin:$PATH"
55-
ENV PYTHONPATH="/app"
52+
ENV PATH="/interactive_ai/services/resource/.venv/bin:$PATH"
53+
ENV PYTHONPATH="/interactive_ai/services/resource:/interactive_ai/services/resource/app"
5654

5755
USER non-root
58-
WORKDIR /app/communication
56+
WORKDIR /interactive_ai/services/resource/app/communication
5957
CMD ["python", "main.py"]

0 commit comments

Comments
 (0)