Update deploy-dev.yml #5
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 to Development | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| - name: Load Environment Variables | |
| uses: falti/dotenv-action@v1.1.4 | |
| with: | |
| export-variables: true | |
| keys-case: bypass | |
| - name: Build Docker Image for Frontend | |
| run: | | |
| sudo docker build -t myapp:latest -f frontend/Dockerfile . | |
| - name: Stop Existing Container | |
| run: | | |
| # If a container is running, stop and remove it | |
| docker rm -f myapp_container || true | |
| - name: Run New Container | |
| run: | | |
| # Run the new container in detached mode. | |
| # Map host port 8080 to container port 3000 (adjust as necessary) | |
| docker run -d --name myapp_container -p 8080:3000 myapp:latest | |
| - name: Verify Deployment | |
| run: docker ps |