-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
71 lines (59 loc) · 2.13 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
71 lines (59 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# variables:
# CI_REGISTRY_IMAGE: registry.gitlab.com/odm-autoassess/app
# CI_COMMIT_TAG: latest
stages:
# - test
- build
# - deploy
docker-build:
stage: build
tags:
- shell
only:
refs:
- tags
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
### Docker-in-Docker is better if:
# ✅ You are using GitLab SaaS Shared Runner (no host Docker access).
# ✅ You want an isolated environment without access to the host system.
# Security is an important concern (no direct host interaction).
# But: Has more overhead and can be slower for large builds.
# build_image:
# stage: build
# image: docker:20.10.16
# services:
# - docker:20.10.16-dind
# variables:
# DOCKER_TLS_CERTDIR: "/certs"
# before_script:
# - docker login -u $REGISTRY_USER -p $REGISTRY_PASS
# script:
# - docker build -t $IMAGE_NAME:$IMAGE_TAG .
# - docker push $IMAGE_NAME:$IMAGE_TAG
# deploy:
# stage: deploy
# tags:
# - imi-runner-container
# before_script:
# # Erstelle das SSH-Verzeichnis, falls nicht vorhanden
# - mkdir -p ~/.ssh
# # Speichere den privaten SSH-Schlüssel aus GitLab Variablen
# - echo "$SSH_PRIVATE_KEY" | base64 -d > ~/.ssh/id_rsa
# # Setze die richtigen Berechtigungen für den privaten Schlüssel
# - chmod 600 ~/.ssh/id_rsa
# # Füge den Server-Fingerprint zur known_hosts Datei hinzu
# - ssh-keyscan -H odm-auto-assess.mi.intern >> ~/.ssh/known_hosts
# script:
# # Teste die SSH-Verbindung zur VM
# - ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa husseinelyas@odm-auto-assess.mi.intern "echo 'Connected successfully!'"
# # docker login -u -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY &&
# # cd /path/to/your/app &&
# # docker-compose down &&
# # docker-compose pull &&
# # docker-compose up -d"
# # docker ps -aq | xargs docker stop | xargs docker rm &&
# # docker run -d -p 5000:5000 $IMAGE_NAME:$IMAGE_TAG"