From 20992c2c91189a5b915809e86d8434824577facc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szak=C3=A1ts=20Alp=C3=A1r=20Zsolt?= Date: Wed, 6 Aug 2025 16:04:03 +0200 Subject: [PATCH] Adds CI/CD workflow for Docker builds Implements a workflow that builds, pushes, and runs a Docker container on push to the main branch. This automates the process of building and deploying the application, ensuring that the latest changes are always reflected in the running container. It also handles stopping and removing existing containers before running the new one. --- .gitea/workflows/docker-build.yml | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .gitea/workflows/docker-build.yml diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml new file mode 100644 index 0000000..9f5f8f3 --- /dev/null +++ b/.gitea/workflows/docker-build.yml @@ -0,0 +1,32 @@ +name: Build, Push and Run Container + +on: + push: + branches: + - main + +jobs: + build: + runs-on: [docker] + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build Docker image + run: docker build -t docker-registry.automatic-parking.dev/automatic-parking:poc Source/ProofOfConcept + + - name: Push to local registry + run: docker push docker-registry.automatic-parking.dev/automatic-parking:poc + + - name: Stop existing container (if running) + run: | + if docker ps -a --format '{{.Names}}' | grep -q '^automatic-parking$'; then + docker rm -f automatic-parking + fi + + - name: Run new container + run: | + docker run -d \ + --name automatic-parking \ + -p 8080:80 \ + docker-registry.automatic-parking.dev/automatic-parking:poc \ No newline at end of file