Skip to content

Commit 959d969

Browse files
Continuous-Deployment
1 parent 0225e57 commit 959d969

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

.github/workflows/main.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,38 @@ jobs:
6060
# be deployed to ECS.
6161
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
6262
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
63-
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
63+
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
64+
65+
Continuous-Deployment:
66+
needs: build-and-push-ecr-image
67+
runs-on: self-hosted
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v3
71+
72+
- name: Configure AWS credentials
73+
uses: aws-actions/configure-aws-credentials@v1
74+
with:
75+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
76+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
77+
aws-region: ${{ secrets.AWS_REGION }}
78+
79+
- name: Login to Amazon ECR
80+
id: login-ecr
81+
uses: aws-actions/amazon-ecr-login@v1
82+
83+
84+
- name: Pull latest images
85+
run: |
86+
docker pull ${{secrets.AWS_ECR_LOGIN_URI}}/${{ secrets.ECR_REPOSITORY_NAME }}:latest
87+
88+
#- name: Stop and remove container if running
89+
# run: |
90+
# docker ps -q --filter "name=networksecurity" | grep -q . && docker stop networksecurity && docker rm -fv networksecurity
91+
92+
- name: Run Docker Image to serve users
93+
run: |
94+
docker run -d -p 8080:8080 --ipc="host" --name=networksecurity -e 'AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}' -e 'AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}' -e 'AWS_REGION=${{ secrets.AWS_REGION }}' ${{secrets.AWS_ECR_LOGIN_URI}}/${{ secrets.ECR_REPOSITORY_NAME }}:latest
95+
- name: Clean previous images and containers
96+
run: |
97+
docker system prune -f

app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,5 @@ async def predict_route(request: Request,file: UploadFile = File(...)):
8686

8787

8888
if __name__=="__main__":
89-
#app_run(app,host="0.0.0.0",port=8000)
90-
app_run(app,host="localhost",port=8000) # uvicorn app:app --reload or python app.py
89+
app_run(app,host="0.0.0.0",port=8000)
90+
#app_run(app,host="localhost",port=8000) # uvicorn app:app --reload or python app.py

0 commit comments

Comments
 (0)