Skip to content

Update Dockerfile

Update Dockerfile #21

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- master
env:
IMAGE_NAME: muhammadahmed1127/instagram-clone
IMAGE_TAG: backend-1.0
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASS }}
- name: Build Docker image
run: docker build -t $IMAGE_NAME:$IMAGE_TAG ./
- name: Push Docker image to Docker Hub
run: docker push $IMAGE_NAME:$IMAGE_TAG
deploy:
runs-on: ubuntu-20.04
needs: build
steps:
- name: SSH into server and deploy Docker image
uses: appleboy/ssh-action@master
with:
host: 64.23.148.21
username: root
key: ${{ secrets.SSH_KEY }}
script: |
apt update && apt install docker.io -y
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASS }}
docker ps -aq | xargs docker stop | xargs docker rm
docker run -d -p 5000:3001 muhammadahmed1127/instagram-clone:backend-1.0