diff --git a/.github/workflows/push_image_to_ecr.yml b/.github/workflows/push_image_to_ecr.yml new file mode 100644 index 0000000..e0e7ac6 --- /dev/null +++ b/.github/workflows/push_image_to_ecr.yml @@ -0,0 +1,45 @@ +name: Deploy to ECR + +on: + push: + branches: [ master ] + +jobs: + + build: + + name: Build Image + runs-on: ubuntu-latest + + + steps: + + - name: Check out code + uses: actions/checkout@v2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} + AWS_REGION: us-east-1 + + - name: Build, test, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: clo835-week3 + IMAGE_TAG: v0.1 + run: | + cd Chapter02/kubia/ + ls -ltra + # Docker build + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + # Unit test + docker run -d -p 80:8080 --name nodeapp $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker ps + echo "Pause for 10 seconds to let container start" + sleep 10 + curl localhost -vvv + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG diff --git a/Chapter02/kubia/Dockerfile b/Chapter02/kubia/Dockerfile index c70e4c8..b9e0944 100644 --- a/Chapter02/kubia/Dockerfile +++ b/Chapter02/kubia/Dockerfile @@ -1,4 +1,5 @@ FROM node:7 ADD app.js /app.js +#This is the entrypoint of the Node ENTRYPOINT ["node", "app.js"] diff --git a/key.txt b/key.txt new file mode 100644 index 0000000..2c12025 --- /dev/null +++ b/key.txt @@ -0,0 +1 @@ +HH03H-VGJDP-P8LJA-0HCRM-AD1P0 \ No newline at end of file