Skip to content

Commit

Permalink
deploy to ec2 3
Browse files Browse the repository at this point in the history
  • Loading branch information
RamyAlshurafa committed Dec 17, 2023
1 parent 0181cf5 commit b8a0985
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .github/workflows/ec2-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,33 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: |
~/.docker
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }}
restore-keys: |
${{ runner.os }}-docker-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

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

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ./
push: true
dockerfile: ./Dockerfile
tags: ramyshurafa/strapi:latest

deploy:
needs: build
runs-on: ubuntu-latest
Expand All @@ -53,4 +66,4 @@ jobs:
ssh -o StrictHostKeyChecking=no -i key.pem ${{ env.VM_IP }} 'docker rm strapi || true'
- name: Run new container
run: |
ssh -o StrictHostKeyChecking=no -i key.pem ${{ env.VM_IP }} 'docker run -d --name strapi -p 80:3000 ramyshurafa/strapi:latest'
ssh -o StrictHostKeyChecking=no -i key.pem ${{ env.VM_IP }} 'docker run -d --name strapi -p 80:1337 ramyshurafa/strapi:latest'

0 comments on commit b8a0985

Please sign in to comment.