-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
60 lines (42 loc) · 1.99 KB
/
.gitlab-ci.yml
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
---
stages:
- cleanup
- build
- deploy
cleanup:
stage: cleanup
script:
# Stop any containers with names starting with 'scaler-w1-'
- docker ps -aq --filter "name=scaler-w1-" | xargs -r docker stop || echo "Failed to stop some containers."
- docker ps -aq --filter "name=openstack-exporter-" | xargs -r docker stop || echo "Failed to stop some containers."
# Wait for a few seconds to ensure everything is settled
- sleep 10
- docker ps -aq --filter "name=openstack-exporter-" | xargs -r docker rm || echo "Failed to remove some containers."
- docker ps -aq --filter "name=scaler-w1-" | xargs -r docker rm || echo "Failed to remove some containers."
# Remove images with names containing 'scaler' or 'openstack-exporter'
- docker images -q | grep 'scaler' | xargs -r docker rmi || echo "Failed to remove some scaler images."
- docker images -q | grep 'openstack-exporter' | xargs -r docker rmi || echo "Failed to remove some openstack-exporter images."
scaler_build:
stage: build
script:
- echo "Stage build, Dockerfile:"
- cd apps/Scaling
- cat Dockerfile
- docker build -t scaler:$CI_PIPELINE_ID .
openstack_exporter_build:
stage: build
script:
- echo "Stage build, Dockerfile:"
- cd apps/OpenStack
- cat Dockerfile
- docker build -t openstack-exporter:$CI_PIPELINE_ID .
openstack_exporter_deploy:
stage: deploy
script:
- docker images | grep openstack-exporter
- docker run -d -p 5000:5000 --restart=unless-stopped -e OS_AUTH_URL=$OS_AUTH_URL -e OS_PROJECT_NAME=$OS_PROJECT_NAME -e OS_USERNAME=$OS_USERNAME -e OS_PASSWORD="$OS_PASSWORD" --name openstack-exporter-$CI_PIPELINE_ID openstack-exporter:$CI_PIPELINE_ID
- docker ps
scaler deploy:
stage: deploy
script:
- docker run -d -p 7474:7474 --restart=unless-stopped -e OS_AUTH_URL="$OS_AUTH_URL" -e OS_PROJECT_NAME="$OS_PROJECT_NAME" -e OS_USERNAME="$OS_USERNAME" -e OS_PASSWORD="$OS_PASSWORD" --name scaler-w1-$CI_PIPELINE_ID scaler:$CI_PIPELINE_ID