This commit is contained in:
Murat Özkorkmaz
2025-10-17 15:51:04 +02:00
parent 61ee0b6e89
commit 1077322477
10 changed files with 408 additions and 0 deletions

70
.gitea-ci.yml Normal file
View File

@@ -0,0 +1,70 @@
version: "1"
stages:
- build
- push
- deploy
variables:
IMAGE_NAME: angular-web-app
TAG: ${CI_COMMIT_TAG:-latest}
GITEA_REGISTRY: ${CI_REGISTRY}
build-image:
stage: build
image: docker:latest
services:
- docker:dind
before_script:
- apk add --no-cache bash
- chmod +x ./build.sh ./push-to-gitea.sh
script:
- echo "🏗️ Baue Docker-Image..."
- ./build.sh "$IMAGE_NAME" "$TAG"
artifacts:
paths:
- Dockerfile
push-image:
stage: push
image: docker:latest
services:
- docker:dind
before_script:
- apk add --no-cache bash
- chmod +x ./push-to-gitea.sh
script:
- echo "⬆️ Push zu Gitea Registry..."
- |
export GITEA_REGISTRY="${CI_REGISTRY}"
export GITEA_USER="${CI_REGISTRY_USER}"
export GITEA_TOKEN="${CI_REGISTRY_TOKEN}"
./push-to-gitea.sh "$IMAGE_NAME" "$TAG"
only:
- main
- tags
deploy:
stage: deploy
image: alpine:latest
needs:
- push-image
only:
- main
- tags
script:
- echo "🚀 Deployment auf Zielserver starten..."
- apk add --no-cache openssh-client docker-cli
- echo "${DEPLOY_KEY}" > /tmp/deploy_key.pem
- chmod 600 /tmp/deploy_key.pem
- |
ssh -i /tmp/deploy_key.pem -o StrictHostKeyChecking=no ${DEPLOY_USER}@${DEPLOY_HOST} <<EOF
echo "📦 Pull aktuelles Image aus Registry..."
docker login ${GITEA_REGISTRY} -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_TOKEN}"
docker pull ${GITEA_REGISTRY}/${CI_REGISTRY_USER}/${IMAGE_NAME}:${TAG}
echo "🛑 Stoppe alten Container (falls vorhanden)..."
docker stop ${IMAGE_NAME} || true
docker rm ${IMAGE_NAME} || true
echo "🚀 Starte neuen Container..."
docker run -d --name ${IMAGE_NAME} -p 80:80 ${GITEA_REGISTRY}/${CI_REGISTRY_USER}/${IMAGE_NAME}:${TAG}
EOF