Skip to content

Commit

Permalink
control-service: Add vdk-heartbeat image
Browse files Browse the repository at this point in the history
As part of the the CI/CD process, we could benefit from
having the vdk-heartbeat package built as a docker image.

This change adds a dockerfile to facilitate building the
vdk-heartbeat docker image when a new release of the
Control Service is made.

Testing Done: Built the image in docker locally and
ran it to verify that it is being executed as expected.

Signed-off-by: Andon Andonov <[email protected]>
  • Loading branch information
doks5 committed Oct 5, 2021
1 parent cea160c commit 8b3f4fe
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
26 changes: 26 additions & 0 deletions projects/control-service/cicd/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,29 @@ control_service_release:
- main
changes:
- projects/control-service/projects/helm_charts/pipelines-control-service/version.txt

control_service_vdk_heartbeat_release:
image: docker:19.03.8
services:
- docker:19.03.8-dind
variables:
DOCKER_HOST: tcp://localhost:2375
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
stage: release
script:
- export CHART_NAME=pipelines-control-service
- export CHART_VERSION=$(cat projects/control-service/projects/helm_charts/$CHART_NAME/version.txt)
- export VDK_HEARTBEAT_TEST_IMAGE_NAME=$CHART_NAME-integration-tests:0.0.1
- docker login $VDK_DOCKER_REGISTRY_URL --username $VDK_DOCKER_REGISTRY_USERNAME --password $VDK_DOCKER_REGISTRY_PASSWORD
- cd projects/control-service/cicd
- docker build --tag $VDK_HEARTBEAT_TEST_IMAGE_NAME -f Dockerfile.vdk.heartbeat .
- docker push $VDK_HEARTBEAT_TEST_IMAGE_NAME
retry: !reference [.control_service_retry, retry_options]
only:
refs:
- external_pull_requests
- main
changes:
# - projects/control-service/projects/helm_charts/pipelines-control-service/version.txt
- projects/control-service/cicd/**/*
25 changes: 25 additions & 0 deletions projects/control-service/cicd/Dockerfile.vdk.heartbeat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Install all required packages and prepare vdk heartbeat
FROM python:3.7-slim AS builder

RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential gcc

RUN python -m venv /opt/buildenv
ENV PATH="/opt/buildenv/bin:$PATH"

RUN pip install -U pip wheel
RUN pip install vdk-heartbeat


# Prepare the release heartbeat
FROM python:3.7-slim

COPY --from=builder /opt/buildenv /opt/buildenv
COPY vdk_heartbeat_config.ini heartbeat_config.ini
COPY start_heartbeat.sh .

RUN ["chmod", "+x", "start_heartbeat.sh"]

ENV PATH="/opt/buildenv/bin:$PATH"

CMD ["./start_heartbeat.sh", "heartbeat_config.ini"]
11 changes: 11 additions & 0 deletions projects/control-service/cicd/start_heartbeat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Copyright 2021 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0

VDK_HEARTBEAT_VDK_DISTRIBUTION_NAME=${VDK_HEARTBEAT_VDK_DISTRIBUTION_NAME:-'quickstart-vdk'}
VDK_HEARTBEAT_PIP_EXTRA_INDEX_URL=${VDK_HEARTBEAT_PIP_EXTRA_INDEX_URL:-'https://pypi.org/simple'}

pip install -U $VDK_HEARTBEAT_VDK_DISTRIBUTION_NAME --extra-index-url $VDK_HEARTBEAT_PIP_EXTRA_INDEX_URL

vdk-heartbeat -f $1
11 changes: 11 additions & 0 deletions projects/control-service/cicd/vdk_heartbeat_config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[DEFAULT]
# Genereate with https://console-stg.cloud.vmware.com/csp/gateway/portal/#/user/tokens
# VDKCLI_OAUTH2_REFRESH_TOKEN= passed as environment variable

JOB_RUN_TEST_MODULE_NAME=vdk.internal.heartbeat.simple_run_test
JOB_RUN_TEST_CLASS_NAME=SimpleRunTest
DATAJOB_DIRECTORY_NAME=simple

VDK_COMMAND_NAME=vdk

REPORT_JUNIT_XML_FILE_PATH=/reports/tests.xml

0 comments on commit 8b3f4fe

Please sign in to comment.