@@ -17,6 +17,7 @@ ARG ML_WEB_ROOT_PATH
1717ARG ML_OR_KEYCLOAK_URL
1818ARG ML_OR_URL
1919
20+ # Run the front-end bundle in production mode
2021RUN 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..."
3132WORKDIR /app
3233
3334ENV PYTHONUNBUFFERED=1 \
34- PYTHONDONTWRITEBYTECODE=1 \
35- PIP_NO_CACHE_DIR=1 \
36- PIP_DISABLE_PIP_VERSION_CHECK=1
35+ PYTHONDONTWRITEBYTECODE=1
3736
3837RUN echo "Installing Python build dependencies..."
3938RUN 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 ./
4649COPY src/ ./src/
4750COPY scripts/ ./scripts/
51+ COPY packages/ ./packages/
4852
49- # Install project dependencies and clean up
53+ # Install project dependencies using uv
5054RUN 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
6771ENV 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
7477RUN echo "Installing runtime dependencies..."
7578RUN 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 ./
8788COPY src/ ./src/
8889COPY 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
9197RUN echo "Copying frontend build artifacts..."
9298COPY --from=frontend-builder /app/frontend/dist/ ./deployment/web/dist/
9399RUN rm -rf /app/frontend
@@ -100,9 +106,9 @@ RUN mkdir -p ./deployment/data/models ./deployment/data/configs
100106EXPOSE 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
105111RUN 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