diff --git a/app/api/predict/Dockerfile b/app/Dockerfile.apipredict similarity index 65% rename from app/api/predict/Dockerfile rename to app/Dockerfile.apipredict index 2d17620..bd9051c 100644 --- a/app/api/predict/Dockerfile +++ b/app/Dockerfile.apipredict @@ -5,19 +5,22 @@ WORKDIR /app COPY ./app/api/predict/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -COPY ./app/api/predict /app -COPY ./ml/models /app +COPY ./app/api/predict /app/src +COPY ./ml/models/model.pkl /app/model.pkl ENV PYTHONDONTWRITEBYTECODE=1 \ - PYTHONUNBUFFERED=1 \ - PYTHONPATH=/app + PYTHONUNBUFFERED=1 \ + PYTHONPATH=/app/src RUN adduser --disabled-password --gecos "" appuser +RUN chown -R appuser:appuser /app + USER appuser EXPOSE 8000 -CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] +# TODO remove hot reloading for production +CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8000/health || exit 1 diff --git a/app/streamlit/Dockerfile b/app/Dockerfile.streamlit similarity index 89% rename from app/streamlit/Dockerfile rename to app/Dockerfile.streamlit index 0f90f52..461af09 100644 --- a/app/streamlit/Dockerfile +++ b/app/Dockerfile.streamlit @@ -3,7 +3,7 @@ FROM python:3.12-slim WORKDIR /app -COPY . /app +COPY ./streamlit /app RUN pip install --no-cache-dir -r requirements.txt diff --git a/app/docker-compose.yml b/app/docker-compose.yml index f5391f1..bcb7ca6 100644 --- a/app/docker-compose.yml +++ b/app/docker-compose.yml @@ -2,13 +2,12 @@ services: api-predict: build: context: .. - dockerfile: app/api/predict/Dockerfile - image: api-predict + dockerfile: app/Dockerfile.apipredict container_name: api-predict ports: - "8002:8000" volumes: - - ./api/predict:/app/predict # TODO remove for production + - ./api/predict:/app/src # TODO remove for production environment: MLFLOW_TRACKING_URI: ${MLFLOW_TRACKING_URI} networks: @@ -16,9 +15,8 @@ services: streamlit: build: - context: streamlit - dockerfile: Dockerfile - image: streamlit + context: . + dockerfile: Dockerfile.streamlit container_name: streamlit ports: - "8501:8501"