Skip to content

Commit

Permalink
refac: changing image registry saving point to AWS Public ECR
Browse files Browse the repository at this point in the history
  • Loading branch information
Lim-Changi committed Aug 31, 2024
1 parent 3bef97f commit c726b2d
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions .github/workflows/cd.develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v3
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./dockerfile
platforms: linux/amd64
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest

- name: Push Image to AWS ECR Public Repo
id: ecr-image-push
run: |
aws ecr-public get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin public.ecr.aws/${{ secrets.AWS_ACCOUNT_ID }}
docker build -t ${{ secrets.ECR_REPOSITORY }}:latest .
docker tag ${{ secrets.ECR_REPOSITORY }}:latest public.ecr.aws/${{ secrets.AWS_ACCOUNT_ID }}/${{ secrets.ECR_REPOSITORY }}:latest
docker push public.ecr.aws/${{ secrets.AWS_ACCOUNT_ID }}/${{ secrets.ECR_REPOSITORY }}:latest
deploy:
needs: build
Expand All @@ -66,6 +49,6 @@ jobs:
sudo docker rm dev-server
sudo docker rm -f $(docker ps -qa)
sudo docker image prune -a -f
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest
sudo docker run --name dev-server --env-file .env -d -p 3000:3000 -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest
sudo docker pull public.ecr.aws/${{ secrets.AWS_ACCOUNT_ID }}/${{ secrets.ECR_REPOSITORY }}:latest
sudo docker run --name dev-server --env-file .env -d -p 3000:3000 -t public.ecr.aws/${{ secrets.AWS_ACCOUNT_ID }}/${{ secrets.ECR_REPOSITORY }}:latest

0 comments on commit c726b2d

Please sign in to comment.