Skip to content

Commit

Permalink
Add Dockerfiles and docker-compose.yml for FastAPI
Browse files Browse the repository at this point in the history
and Streamlit images
  • Loading branch information
sahi-mfg committed Dec 3, 2023
1 parent cfa8b59 commit 0f78a06
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
run: docker run age-detection-api-image python -m pytest tests/
4 changes: 2 additions & 2 deletions Dockerfile → Dockerfile.fastapi
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
CMD ["uvicorn","main:app", "--port","5001", "--host","127.0.0"]
12 changes: 12 additions & 0 deletions Dockerfile.streamlit
Original file line number Diff line number Diff line change
@@ -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"]
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0f78a06

Please sign in to comment.