Adds CI/CD workflow for Docker builds
Some checks failed
Build, Push and Run Container / build (push) Failing after 1s
Some checks failed
Build, Push and Run Container / build (push) Failing after 1s
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.
This commit is contained in:
32
.gitea/workflows/docker-build.yml
Normal file
32
.gitea/workflows/docker-build.yml
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user