# .gitlab-ci.yml
#
# tetcore-analytics (derived from tetcore ci)
#
# pipelines can be triggered manually in the web
# setting DEPLOY_TAG will only deploy the tagged image
#
stages:
- test
- dockerize
- deploy
variables:
GIT_STRATEGY: fetch
CI_SERVER_NAME: "GitLab CI"
CARGO_HOME: "/ci-cache/tetcore-analytics/cargo/${CI_JOB_NAME}"
.kubernetes-build:
tags:
- kubernetes-tetcoin-build
environment:
name: tetcoin-build
#### stage: test
# test-linux-stable:
# stage: test
# # doesn't contain libpq
# image: tetcoin/rust-tetcore-build:stretch
# variables:
# RUST_TOOLCHAIN: stable
# # Enable debug assertions since we are running optimized builds for testing
# # but still want to have debug assertions.
# RUSTFLAGS: -Cdebug-assertions=y
# TARGET: native
# tags:
# - linux-docker
# only:
# - tags
# - master
# - schedules
# - web
# - /^[0-9]+$/
# except:
# variables:
# - $DEPLOY_TAG
# before_script:
# - sccache -s
# script:
# - time cargo test --all --release --verbose --locked
# after_script:
# - sccache -s
.build-only:
only:
- master
- tags
- web
#### stage: dockerize
build-publish-docker-release:
<<: *build-only
<<: *kubernetes-build
stage: dockerize
image: quay.io/buildah/stable
# collect VERSION artifact here to pass it on to kubernetes
variables:
# GIT_STRATEGY: none
# DOCKERFILE: scripts/docker/Dockerfile
CONTAINER_IMAGE: tetcoin/tetcore-analytics
before_script:
- test "$Docker_Hub_User_Tetcoin" -a "$Docker_Hub_Pass_Tetcoin" ||
( echo "no docker credentials provided"; exit 1 )
- echo "$Docker_Hub_Pass_Tetcoin" |
buildah login --username "$Docker_Hub_User_Tetcoin" --password-stdin docker.io
- buildah info
script:
- buildah bud
--format=docker
--tag "$CONTAINER_IMAGE:$CI_COMMIT_SHORT_SHA"
--tag "$CONTAINER_IMAGE:latest" .
- buildah push --format=v2s2 $CONTAINER_IMAGE:$CI_COMMIT_SHORT_SHA
- buildah push --format=v2s2 $CONTAINER_IMAGE:latest
after_script:
- buildah logout docker.io
except:
variables:
- $DEPLOY_TAG
.deploy-template:
<<: *build-only
stage: deploy
when: manual
retry: 1
image: tetcointech/kubetools:latest
variables:
NAMESPACE: "${KUBE_NAMESPACE}"
REPLICAS: 1
WS_PORT: 1024
ANALYTICS_LOG_EXPIRY_H: 3
ANALYTICS_RUST_LOG: debug
WS_MAX_PAYLOAD: 524_288 # Needs to be more than 65_536 (64KiB) which is actix-web default
ASSETS_PATH: /srv/tetcore-analytics
tags:
# this is the runner that is used to deploy it
- kubernetes-tetcoin-build
before_script:
- kubectl version
- test "${DEPLOY_TAG}" || DEPLOY_TAG="$CI_COMMIT_SHORT_SHA"
script:
- echo "Tetcore-analytics version = ${DEPLOY_TAG}"
- export TETCORE_ANALYTICS_DOCKER_IMAGE="tetcoin/tetcore-analytics:${DEPLOY_TAG}"
# or use helm to render the template
- cat ./deployment.template.yml | envsubst | tee deployment.yaml
- kubectl apply -n "$KUBE_NAMESPACE" -f ./deployment.yaml
- rm -f ./deployment.yaml
- echo "# tetcore-analytics namespace ${KUBE_NAMESPACE}"
- kubectl -n ${KUBE_NAMESPACE} get all
- echo "# wait for the rollout to complete"
- kubectl -n ${KUBE_NAMESPACE} rollout status deployment/tetcore-analytics
# have environment:url eventually point to the logs
.deploy-cibuild:
<<: *deploy
dependencies:
- build-publish-docker-release
except:
variables:
- $DEPLOY_TAG
.deploy-tag:
<<: *deploy
only:
variables:
- $DEPLOY_TAG
# have environment:url eventually point to the logs
deploy-ew3:
<<: *deploy-cibuild
environment:
name: tetcoin-prod-ew3
# deploy-ue1:
# extends: .deploy-cibuild
# environment:
# name: tetcoin-prod-ue1
deploy-ew3-tag:
<<: *deploy-tag
environment:
name: tetcoin-prod-ew3
# deploy-ue1-tag:
# extends: .deploy-tag
# environment:
# name: tetcoin-prod-ue1