Skip to content

Commit 0f92205

Browse files
Resolve docker image failing after uv workspace addition
1 parent 38b2db7 commit 0f92205

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

docker/Dockerfile

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ARG ML_WEB_ROOT_PATH
1717
ARG ML_OR_KEYCLOAK_URL
1818
ARG ML_OR_URL
1919

20+
# Run the front-end bundle in production mode
2021
RUN ML_SERVICE_URL=${ML_SERVICE_URL:-/services/ml-forecast} \
2122
ML_WEB_ROOT_PATH=${ML_WEB_ROOT_PATH:-/services/ml-forecast/ui} \
2223
ML_OR_KEYCLOAK_URL=${ML_OR_KEYCLOAK_URL:-/auth} \
@@ -31,24 +32,27 @@ RUN echo "Starting Python build phase..."
3132
WORKDIR /app
3233

3334
ENV PYTHONUNBUFFERED=1 \
34-
PYTHONDONTWRITEBYTECODE=1 \
35-
PIP_NO_CACHE_DIR=1 \
36-
PIP_DISABLE_PIP_VERSION_CHECK=1
35+
PYTHONDONTWRITEBYTECODE=1
3736

3837
RUN echo "Installing Python build dependencies..."
3938
RUN apt-get update \
4039
&& apt-get install -y --no-install-recommends \
4140
build-essential \
41+
curl \
4242
&& rm -rf /var/lib/apt/lists/*
4343

44-
# Copy project files
45-
COPY pyproject.toml README.md ./
44+
# Install uv
45+
RUN pip install uv
46+
47+
# Copy the necessary project files
48+
COPY pyproject.toml uv.lock README.md ./
4649
COPY src/ ./src/
4750
COPY scripts/ ./scripts/
51+
COPY packages/ ./packages/
4852

49-
# Install project dependencies and clean up
53+
# Install project dependencies using uv
5054
RUN echo "Installing Python project dependencies..."
51-
RUN pip install --no-cache-dir . \
55+
RUN uv sync --no-cache-dir \
5256
&& apt-get remove -y build-essential \
5357
&& apt-get autoremove -y \
5458
&& rm -rf /var/lib/apt/lists/* \
@@ -67,27 +71,29 @@ ARG ML_ENVIRONMENT
6771
ENV PYTHONUNBUFFERED=1 \
6872
PYTHONDONTWRITEBYTECODE=1 \
6973
PYTHONPATH=/app/src \
70-
# Use the ARG, falling back to a default if not provided during build or runtime
7174
ML_ENVIRONMENT=${ML_ENVIRONMENT:-production}
7275

73-
# Install runtime dependencies and clean up
76+
# Install any runtime dependencies
7477
RUN echo "Installing runtime dependencies..."
7578
RUN apt-get update \
7679
&& apt-get install -y --no-install-recommends \
7780
curl \
7881
&& rm -rf /var/lib/apt/lists/*
7982

80-
# Copy installed packages from builder
81-
RUN echo "Copying Python packages from builder..."
82-
COPY --from=builder /usr/local/lib/python3.13/site-packages/ /usr/local/lib/python3.13/site-packages/
83-
COPY --from=builder /usr/local/bin/ /usr/local/bin/
83+
# Install uv package manager
84+
RUN pip install uv
8485

8586
# Copy application code
86-
COPY pyproject.toml ./
87+
COPY pyproject.toml uv.lock README.md ./
8788
COPY src/ ./src/
8889
COPY scripts/ ./scripts/
90+
COPY packages/ ./packages/
91+
92+
# Install project dependencies using uv
93+
RUN echo "Installing Python project dependencies..."
94+
RUN uv sync --no-cache-dir
8995

90-
# Copy frontend build and clean up
96+
# Copy frontend build artifacts
9197
RUN echo "Copying frontend build artifacts..."
9298
COPY --from=frontend-builder /app/frontend/dist/ ./deployment/web/dist/
9399
RUN rm -rf /app/frontend
@@ -100,9 +106,9 @@ RUN mkdir -p ./deployment/data/models ./deployment/data/configs
100106
EXPOSE 8000
101107

102108
# Add health check
103-
HEALTHCHECK --interval=5s --timeout=5s --start-period=30s --retries=3 CMD curl --fail --silent http://localhost:8000/ui || exit 1
109+
HEALTHCHECK --interval=10s --timeout=10s --start-period=30s --retries=3 CMD curl --fail --silent http://localhost:8000/ui || exit 1
104110

105111
RUN echo "Container setup complete! Starting application..."
106112

107-
# Run the application
108-
CMD ["python", "-m", "service_ml_forecast.main"]
113+
# Run the application using uv run to ensure virtual environment is activated
114+
CMD ["uv", "run", "python", "-m", "service_ml_forecast.main"]

0 commit comments

Comments
 (0)