-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
70 lines (64 loc) · 2.79 KB
/
.gitlab-ci.yml
File metadata and controls
70 lines (64 loc) · 2.79 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
image: $CI_REGISTRY/mouse-informatics/docker:latest
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DEPLOYMENTS_DIR: /builds/$CI_PROJECT_PATH/deployments
MOUNT_POINT: /builds/$CI_PROJECT_PATH/mnt
CI_REGISTRY: dockerhub.ebi.ac.uk
CI_REGISTRY_IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH
DOCKER_TLS_CERTDIR: ""
stages:
- build-prod
- deploy-prod
build_main_prod_image:
stage: build-prod
services:
- name: $CI_REGISTRY/mouse-informatics/dind:latest
alias: docker
except:
- schedules
before_script:
- mkdir -p "$MOUNT_POINT"
- echo "${CI_REGISTRY_PASSWORD}" | docker login -u "${CI_REGISTRY_USER}" --password-stdin ${CI_REGISTRY}
script:
- sed -i "s|FROM alpine|FROM ${LOCAL_GITLAB_ALPINE_IMAGE}|g" Dockerfile
- |
if [[ "${REQUIRES_REBUILD_IMAGE}" == "true" ]]; then
echo "Building prod image"
docker build -t "${CI_REGISTRY_IMAGE}":latest -f Dockerfile . | tee ${MOUNT_POINT}/build.log
docker push "${CI_REGISTRY_IMAGE}":latest | tee ${MOUNT_POINT}/push.log
docker logout ${CI_REGISTRY}
echo "Pushing to docker hub"
echo "${DOCKER_HUB_PWD}" | docker login --username "${DOCKER_HUB_USER}" --password-stdin
docker tag "${CI_REGISTRY_IMAGE}":latest "${DOCKER_HUB_USER}"/"${DOCKER_HUB_REPO}":latest
docker push "${DOCKER_HUB_USER}"/"${DOCKER_HUB_REPO}":latest | tee ${MOUNT_POINT}/dockerhub-push-latest.log
fi
- docker logout
artifacts:
paths:
- "$MOUNT_POINT/"
only:
refs:
- main
deploy-HH-WP-WEBADMIN-prod:
stage: deploy-prod
image: dtzar/helm-kubectl:2.13.0
script:
- kubectl config set-cluster local --server="${HH_WP_WEBADMIN_ENDPOINT}"
- kubectl config set clusters.local.certificate-authority-data "${HH_WP_WEBADMIN_CERTIFICATE_AUTHORITY}"
- kubectl config set-credentials ${HH_WP_WEBADMIN_PROD_USER} --token="${HH_WP_WEBADMIN_PROD_USER_TOKEN}"
- kubectl config set-context "${HH_WP_WEBADMIN_PROD_NAMESPACE}" --cluster=local --user=${HH_WP_WEBADMIN_PROD_USER} --namespace="${HH_WP_WEBADMIN_PROD_NAMESPACE}"
- kubectl config use-context "${HH_WP_WEBADMIN_PROD_NAMESPACE}"
- kubectl version
- |
if kubectl apply -f K8s/main/deployment.yaml -n pdcm-data-dashboard --record | grep -q unchanged; then
echo "=> Patching deployment to force image update."
kubectl patch -f K8s/main/deployment.yaml -n pdcm-data-dashboard --record -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"ci-last-updated\":\"$(date +'%s')\"}}}}}"
else
echo "=> Deployment apply has changed the object, no need to force image update."
fi
- kubectl rollout status -f K8s/main/deployment.yaml
- kubectl get pods,service,deploy,replicaset,ing -n pdcm-data-dashboard
only:
refs:
- main