From 0f78a06620bd7e8f9708dc1623f2de0b63b133df Mon Sep 17 00:00:00 2001 From: Sahi Mohamed Francis Gonsangbeu Date: Sun, 3 Dec 2023 05:34:41 +0100 Subject: [PATCH] Add Dockerfiles and docker-compose.yml for FastAPI and Streamlit images --- .github/workflows/ci.yml | 9 ++++++--- Dockerfile => Dockerfile.fastapi | 4 ++-- Dockerfile.streamlit | 12 ++++++++++++ docker-compose.yml | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) rename Dockerfile => Dockerfile.fastapi (65%) create mode 100644 Dockerfile.streamlit create mode 100644 docker-compose.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f62ec4b..605fa91 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,11 @@ jobs: with: node-version: 16 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag age-detection-image + - name: Build the FastAPI Docker image + run: docker build . --file Dockerfile.fastapi --tag age-detection-api-image + + - name: Build the streamlit Docker image + run: docker build . --file Dockerfile.streamlit --tag age-detection-ui-image - name: Run tests - run: docker run age-detection-image python -m pytest tests/ \ No newline at end of file + run: docker run age-detection-api-image python -m pytest tests/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile.fastapi similarity index 65% rename from Dockerfile rename to Dockerfile.fastapi index dc71864..455f040 100755 --- a/Dockerfile +++ b/Dockerfile.fastapi @@ -2,6 +2,6 @@ FROM tiangolo/uvicorn-gunicorn:python3.10 WORKDIR /app COPY requirements.txt /tmp/ RUN pip install --no-cache-dir --upgrade -r /tmp/requirements.txt -COPY app/ /app/ +COPY . /app/ -CMD ["uvicorn","main:app", "--port","5000", "--host","127.0.0"] \ No newline at end of file +CMD ["uvicorn","main:app", "--port","5001", "--host","127.0.0"] diff --git a/Dockerfile.streamlit b/Dockerfile.streamlit new file mode 100644 index 0000000..9f3da60 --- /dev/null +++ b/Dockerfile.streamlit @@ -0,0 +1,12 @@ +FROM python:3.10 + +WORKDIR /app + +COPY requirements.txt /tmp/ +RUN pip install --no-cache-dir --upgrade -r /tmp/requirements.txt + +COPY . /app/ + +EXPOSE 8501 + +CMD ["streamlit", "run", "ui/app.py"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..370bf0f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3.10' + +services: + fastapi: + build: + context: . + dockerfile: Dockerfile.fastapi + ports: + - 5001:5000 + + streamlit: + build: + context: . + dockerfile: Dockerfile.streamlit + ports: + - 8501:8501 \ No newline at end of file