diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3586d33..e48b5fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,8 @@ name: Deploy Image to Docker Hub env: APP_NAME: 'prjctr' + STREAMLIT_NAME: 'app-streamlit' + FASTAPI_NAME: 'app-fastapi' on: push: @@ -52,3 +54,12 @@ jobs: run: | docker build . --tag docker.io/${{ secrets.DH_USERNAME }}/$APP_NAME:latest docker push docker.io/${{ secrets.DH_USERNAME }}/$APP_NAME:latest + - name: 'Build & Push Image streamlit' + run: | + docker build . --tag docker.io/${{ secrets.DH_USERNAME }}/$STREAMLIT_NAME:latest + docker push docker.io/${{ secrets.DH_USERNAME }}/$STREAMLIT_NAME:latest + - name: 'Build & Push Image fastapi' + run: | + docker build . --tag docker.io/${{ secrets.DH_USERNAME }}/$FASTAPI_NAME:latest + docker push docker.io/${{ secrets.DH_USERNAME }}/$FASTAPI_NAME:latest + diff --git a/Dockerfile b/Dockerfile index a9482e6..edfa59e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,15 @@ WORKDIR /app COPY app/requirements.txt . RUN pip install -r requirements.txt -FROM builder +FROM builder AS app-flask COPY app . CMD ["gunicorn", "--bind", "0.0.0.0:8000", "app:app"] EXPOSE 8000 + +FROM builder AS app-streamlit +CMD streamlit run --server.address 0.0.0.0 --server.port 8080 src/serving/streamlit.py + + +FROM builder AS app-fastapi +CMD uvicorn --host 0.0.0.0 --port 8090 --workers 4 src.serving.fastapi:app diff --git a/README.md b/README.md index 51b8105..e8a706a 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,21 @@ streamlit run src/serving/streamlit.py ![Alt text](assets/streamlit.png) +Deploy k8s: +``` +kubectl create -f deployment/app-ui.yml +kubectl port-forward --address 0.0.0.0 svc/app-ui.yml 8080:8080 +``` ### Fast API Postman ![Alt text](assets/fastapi.png) + + +Deploy k8s: +``` +kubectl create -f deployment/app-fasttext.yml +kubectl port-forward --address 0.0.0.0 svc/app-fasttext 8090:8090 +``` diff --git a/deployment/app-fastapi.yml b/deployment/app-fastapi.yml new file mode 100644 index 0000000..8d7163b --- /dev/null +++ b/deployment/app-fastapi.yml @@ -0,0 +1,31 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: app-fastapi +spec: + replicas: 2 + selector: + matchLabels: + app: app-fastapi + template: + metadata: + labels: + app: app-fastapi + spec: + containers: + - name: app-fastapi + image: yuriihavrylko/app-fastapi:latest +--- +apiVersion: v1 +kind: Service +metadata: + name: app-fastapi + labels: + app: app-fastapi +spec: + ports: + - port: 8080 + protocol: TCP + selector: + app: app-fastapi diff --git a/deployment/app-ui.yml b/deployment/app-ui.yml new file mode 100644 index 0000000..70badad --- /dev/null +++ b/deployment/app-ui.yml @@ -0,0 +1,31 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: app-fastapi +spec: + replicas: 2 + selector: + matchLabels: + app: app-fastapi + template: + metadata: + labels: + app: app-fastapi + spec: + containers: + - name: app-fastapi + image: yuriihavrylko/app-streamlit:latest +--- +apiVersion: v1 +kind: Service +metadata: + name: app-fastapi + labels: + app: app-fastapi +spec: + ports: + - port: 8080 + protocol: TCP + selector: + app: app-fastapi