Skip to content

Commit 9da4602

Browse files
[MISC] Fix Docker builds for OTEL dependencies and non-root user improvements (#1403)
[MISC] Fixed OTEL dependency installation for builds, updated some builds to use non-root user for syncing venv
1 parent dea97f8 commit 9da4602

6 files changed

Lines changed: 30 additions & 12 deletions

File tree

docker/dockerfiles/backend.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ COPY ${BUILD_PACKAGES_PATH}/ /unstract/
5050

5151
# Install external dependencies from pyproject.toml
5252
RUN uv sync --group deploy --locked --no-install-project --no-dev && \
53+
.venv/bin/python3 -m ensurepip --upgrade && \
5354
uv run opentelemetry-bootstrap -a install
5455

5556
# -----------------------------------------------

docker/dockerfiles/platform.Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ COPY --chown=${APP_USER}:${APP_USER} ${BUILD_CONTEXT_PATH}/pyproject.toml ${BUIL
4949
COPY --chown=${APP_USER}:${APP_USER} ${BUILD_PACKAGES_PATH}/core /unstract/core
5050
COPY --chown=${APP_USER}:${APP_USER} ${BUILD_PACKAGES_PATH}/flags /unstract/flags
5151

52+
# Switch to non-root user
53+
USER ${APP_USER}
54+
5255
# Install external dependencies from pyproject.toml
5356
RUN uv sync --group deploy --locked --no-install-project --no-dev && \
57+
.venv/bin/python3 -m ensurepip --upgrade && \
5458
uv run opentelemetry-bootstrap -a install
5559

5660
# -----------------------------------------------
@@ -61,12 +65,12 @@ FROM ext-dependencies AS production
6165
# Copy application code (this layer changes most frequently)
6266
COPY --chown=${APP_USER}:${APP_USER} ${BUILD_CONTEXT_PATH} ./
6367

68+
# Switch to non-root user
69+
USER ${APP_USER}
70+
6471
# Install the application in non-editable mode to avoid permission issues
6572
RUN uv sync --group deploy --locked
6673

67-
# Switch to non-root user for the rest of the operations
68-
USER ${APP_USER}
69-
7074
EXPOSE 3001
7175

7276
# During debugging, this entry point will be overridden

docker/dockerfiles/prompt.Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ COPY --chown=${APP_USER}:${APP_USER} ${BUILD_CONTEXT_PATH}/pyproject.toml ${BUIL
5151
COPY --chown=${APP_USER}:${APP_USER} ${BUILD_PACKAGES_PATH}/core /unstract/core
5252
COPY --chown=${APP_USER}:${APP_USER} ${BUILD_PACKAGES_PATH}/flags /unstract/flags
5353

54+
# Switch to non-root user
55+
USER ${APP_USER}
56+
5457
# Install external dependencies from pyproject.toml
5558
RUN uv sync --group deploy --locked --no-install-project --no-dev && \
59+
.venv/bin/python3 -m ensurepip --upgrade && \
5660
uv run opentelemetry-bootstrap -a install
5761

5862
# -----------------------------------------------
@@ -63,6 +67,9 @@ FROM ext-dependencies AS production
6367
# Copy application code (this layer changes most frequently)
6468
COPY --chown=${APP_USER}:${APP_USER} ${BUILD_CONTEXT_PATH} ./
6569

70+
# Switch to non-root user
71+
USER ${APP_USER}
72+
6673
# Install just the application in editable mode
6774
RUN uv sync --group deploy --locked
6875

@@ -77,9 +84,6 @@ RUN for dir in "${TARGET_PLUGINS_PATH}"/*/; do \
7784
done && \
7885
mkdir -p prompt-studio-data
7986

80-
# Switch to non-root user
81-
USER ${APP_USER}
82-
8387
EXPOSE 3003
8488

8589
CMD ["./entrypoint.sh"]

docker/dockerfiles/runner.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ COPY ${BUILD_PACKAGES_PATH}/flags /unstract/flags
4747

4848
# Install external dependencies from pyproject.toml
4949
RUN uv sync --group deploy --locked --no-install-project --no-dev && \
50+
.venv/bin/python3 -m ensurepip --upgrade && \
5051
uv run opentelemetry-bootstrap -a install
5152

5253
# -----------------------------------------------

docker/dockerfiles/tool-sidecar.Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ COPY --chown=${APP_USER}:${APP_USER} ${BUILD_CONTEXT_PATH}/pyproject.toml ${BUIL
4848
# Copy local package dependencies
4949
COPY --chown=${APP_USER}:${APP_USER} ${BUILD_PACKAGES_PATH}/core /unstract/core
5050

51+
# Switch to non-root user
52+
USER ${APP_USER}
53+
5154
# Install external dependencies from pyproject.toml
5255
RUN uv sync --group deploy --locked --no-install-project --no-dev && \
56+
.venv/bin/python3 -m ensurepip --upgrade && \
5357
uv run opentelemetry-bootstrap -a install
5458

5559
# -----------------------------------------------
@@ -60,14 +64,14 @@ FROM ext-dependencies AS production
6064
# Copy application code (this layer changes most frequently)
6165
COPY --chown=${APP_USER}:${APP_USER} ${BUILD_CONTEXT_PATH} ./
6266

67+
# Switch to non-root user
68+
USER ${APP_USER}
69+
6370
# Install just the application
6471
RUN uv sync --group deploy --locked && \
6572
chmod +x ./entrypoint.sh
6673

6774
# # Make entrypoint executable
6875
# RUN chmod +x ./entrypoint.sh
6976

70-
# Switch to non-root user
71-
USER ${APP_USER}
72-
7377
CMD ["./entrypoint.sh"]

docker/dockerfiles/x2text.Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ FROM base AS ext-dependencies
4444
# Copy dependency-related files
4545
COPY ${BUILD_CONTEXT_PATH}/pyproject.toml ${BUILD_CONTEXT_PATH}/uv.lock ${BUILD_CONTEXT_PATH}/README.md ./
4646

47+
# Switch to non-root user
48+
USER ${APP_USER}
49+
4750
# Install external dependencies from pyproject.toml
4851
RUN uv sync --group deploy --locked --no-install-project --no-dev && \
52+
.venv/bin/python3 -m ensurepip --upgrade && \
4953
uv run opentelemetry-bootstrap -a install
5054

5155
# -----------------------------------------------
@@ -56,12 +60,12 @@ FROM ext-dependencies AS production
5660
# Copy application code (this layer changes most frequently)
5761
COPY --chown=${APP_USER}:${APP_USER} ${BUILD_CONTEXT_PATH} ./
5862

59-
# Install just the application
60-
RUN uv sync --group deploy --locked
61-
6263
# Switch to non-root user
6364
USER ${APP_USER}
6465

66+
# Install just the application
67+
RUN uv sync --group deploy --locked
68+
6569
EXPOSE 3004
6670

6771
# During debugging, this entry point will be overridden.

0 commit comments

Comments
 (0)