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: Build and run Docker container | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Stop all running Docker containers | |
run: sudo docker stop $(sudo docker ps -aq) | |
- name: Remove all Docker containers | |
run: sudo docker rm $(sudo docker ps -aq) | |
- name: Build the Docker image | |
run: sudo docker build -t backend . | |
- name: Run the Docker container on port 8000 | |
run: sudo docker run -d -p 8000:8000 backend |