docker ec2 #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Node Application | |
on: | |
push: | |
branches: | |
- erp-dev | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: Build Docker Image | |
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/institute-management-backend . | |
- name: Publish Docker Image | |
run: docker push ${{ secrets.DOCKER_USERNAME }}/institute-management-backend:latest | |
publish: | |
needs: build | |
runs-on: self-hosted | |
steps: | |
- name: Pull Docker Image | |
run: docker pull ${{ secrets.DOCKER_USERNAME }}/institute-management-backend:latest | |
- name: Delete old container | |
run: docker rm -f institute-management-backend | |
- name: Run Docker Container | |
run: docker run -d -p 5000:5000 --name institute-management-backend -e MONGO_URI=${{ secrets.MONGO_URI }} ${{ secrets.DOCKER_USERNAME }}/institute-management-backend:latest |