Skip to content

Update Dockerfile

Update Dockerfile #12

Workflow file for this run

name: build-push-deploy
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create .env file
run: |
echo JWT_SECRET=${{ secrets.JWT_SECRET }} >> .env
echo MONGO_URI=${{ secrets.MONGO_URI }} >> .env
echo PORT=${{ vars.PORT }} >> .env
- name: List files in directory (debugging step)
run: ls -la
- name: Display .env file contents
run: cat .env
- name: Build Docker image
run: docker build -t kingitsolutionsteam/nawwa-test:${{ github.sha }} .
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker image to Docker Hub
run: docker push kingitsolutionsteam/nawwa-test:${{ github.sha }}
deploy:
runs-on: nawwa-runner
needs: build-and-push
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Pull Docker image
run: sudo docker pull kingitsolutionsteam/nawwa-test:${{ github.sha }}
- name: Deploy Docker image
run: |
sudo docker run -d -p ${{ vars.PORT }}:9005 kingitsolutionsteam/nawwa-test:${{ github.sha }}