From c536cac99210d8f806d526d1d731f2ac0d4810ad Mon Sep 17 00:00:00 2001 From: Jeff Cheng Date: Mon, 12 Apr 2021 11:17:43 -0400 Subject: [PATCH 1/3] Add docker-otelcol job to circleci --- .circleci/config.yml | 48 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8b9833801b..71c0f1b38d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,6 +23,7 @@ commands: dist/splunk-otel-collector-*.aarch64.rpm dist/splunk-otel-collector-*.x86_64.rpm dist/splunk-otel-collector-*-amd64.msi + dist/image.tar steps: - run: name: Check if files exist @@ -66,9 +67,9 @@ commands: steps: - run: - name: Build image + name: Load and tag image command: | - make docker-otelcol + docker load -i dist/image.tar docker tag otelcol:latest quay.io/signalfx/<< parameters.repo >>:<< parameters.tag >> docker tag otelcol:latest quay.io/signalfx/<< parameters.repo >>:latest - run: @@ -169,6 +170,12 @@ workflows: filters: tags: only: /^v[0-9]+\.[0-9]+\.[0-9]+.*/ + - docker-otelcol: + requires: + - cross-compile + filters: + tags: + only: /^v[0-9]+\.[0-9]+\.[0-9]+.*/ - test: requires: - setup-environment @@ -191,6 +198,7 @@ workflows: - deb-package - rpm-package - windows-msi + - docker-otelcol filters: branches: ignore: /.*/ @@ -206,6 +214,7 @@ workflows: - deb-package - rpm-package - windows-msi + - docker-otelcol filters: branches: only: main @@ -328,6 +337,33 @@ jobs: name: Code coverage command: bash <(curl -s https://codecov.io/bash) + docker-otelcol: + docker: + - image: cimg/go:1.15 + steps: + - attach_to_workspace + - setup_remote_docker + - run: + name: Build docker image + command: make docker-otelcol SKIP_COMPILE=true + - run: + name: Run docker image + command: | + docker run -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=us0 --name otelcol otelcol:latest + sleep 10 + if [ -z "$( docker ps --filter=status=running --filter=name=otelcol -q )" ]; then + docker logs otelcol + exit 1 + fi + - run: + name: Save docker image + command: | + mkdir -p dist + docker save -o dist/image.tar otelcol:latest + - persist_to_workspace: + root: ~/ + paths: project/dist + publish-stable: docker: - image: cimg/go:1.15 @@ -344,6 +380,7 @@ jobs: cp bin/* dist/ # exclude the otelcol symlink from the release [ -e dist/otelcol ] && rm -f dist/otelcol + [ -e dist/image.tar ] && rm -f dist/image.tar - run: name: Calculate checksums command: cd dist && shasum -a 256 * > checksums.txt @@ -397,15 +434,12 @@ jobs: enum: ["deb", "rpm"] steps: - attach_to_workspace - - run: - name: Build fpm image - command: docker build -t otelcol-fpm internal/buildscripts/packaging/fpm - run: name: Build << parameters.package_type >> amd64 package - command: docker run --rm -v $(pwd):/repo -e PACKAGE="<< parameters.package_type >>" -e VERSION="${CIRCLE_TAG:-}" -e ARCH="amd64" otelcol-fpm + command: make << parameters.package_type>>-package SKIP_COMPILE=true VERSION="${CIRCLE_TAG:-}" ARCH="amd64" - run: name: Build << parameters.package_type >> arm64 package - command: docker run --rm -v $(pwd):/repo -e PACKAGE="<< parameters.package_type >>" -e VERSION="${CIRCLE_TAG:-}" -e ARCH="arm64" otelcol-fpm + command: make << parameters.package_type>>-package SKIP_COMPILE=true VERSION="${CIRCLE_TAG:-}" ARCH="arm64" - install_pytest - run: name: Test << parameters.package_type >> package installation From 4f969006e66672435b36c68e9cce6d9c5368e4b8 Mon Sep 17 00:00:00 2001 From: Jeff Cheng Date: Mon, 12 Apr 2021 12:12:03 -0400 Subject: [PATCH 2/3] Add SKIP_COMPILE Makefile var --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 72c7414528..5e0bd00a72 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,7 @@ BUILD_X3=-X $(BUILD_INFO_IMPORT_PATH).BuildType=$(BUILD_TYPE) BUILD_INFO=-ldflags "${BUILD_X1} ${BUILD_X2} ${BUILD_X3}" SMART_AGENT_RELEASE=v5.9.1 +SKIP_COMPILE=false ### FUNCTIONS @@ -189,7 +190,9 @@ delete-tag: .PHONY: docker-otelcol docker-otelcol: +ifneq ($(SKIP_COMPILE), true) GOOS=linux $(MAKE) otelcol +endif cp ./bin/otelcol_linux_amd64 ./cmd/otelcol/otelcol docker build -t otelcol --build-arg SMART_AGENT_RELEASE=$(SMART_AGENT_RELEASE) ./cmd/otelcol/ rm ./cmd/otelcol/otelcol @@ -216,6 +219,8 @@ binaries-windows_amd64: .PHONY: deb-rpm-package %-package: ARCH ?= amd64 %-package: +ifneq ($(SKIP_COMPILE), true) $(MAKE) binaries-linux_$(ARCH) +endif docker build -t otelcol-fpm internal/buildscripts/packaging/fpm docker run --rm -v $(CURDIR):/repo -e PACKAGE=$* -e VERSION=$(VERSION) -e ARCH=$(ARCH) -e SMART_AGENT_RELEASE=$(SMART_AGENT_RELEASE) otelcol-fpm From a8a30c82ad4d550b8bf6d62bd147b6481735a430 Mon Sep 17 00:00:00 2001 From: Jeff Cheng Date: Mon, 12 Apr 2021 12:34:19 -0400 Subject: [PATCH 3/3] Add msi target to Makefile --- .circleci/config.yml | 11 ++++------- Makefile | 8 ++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 71c0f1b38d..794602493c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -349,7 +349,7 @@ jobs: - run: name: Run docker image command: | - docker run -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=us0 --name otelcol otelcol:latest + docker run -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:latest sleep 10 if [ -z "$( docker ps --filter=status=running --filter=name=otelcol -q )" ]; then docker logs otelcol @@ -495,15 +495,12 @@ jobs: docker_layer_caching: true steps: - attach_to_workspace - - run: - name: Build msi-builder image - command: docker build -t msi-builder internal/buildscripts/packaging/msi/msi-builder - run: name: Build MSI command: | - mkdir dist - export VERSION_TAG="${CIRCLE_TAG/v/}" - docker run --rm -v $(pwd):/project -u 0 msi-builder "${VERSION_TAG:-0.0.1.$CIRCLE_BUILD_NUM}" + mkdir -p dist + export VERSION_TAG="${CIRCLE_TAG#v}" + make msi SKIP_COMPILE=true VERSION="${VERSION_TAG:-0.0.1.$CIRCLE_BUILD_NUM}" - persist_to_workspace: root: ~/ paths: project/dist/*.msi diff --git a/Makefile b/Makefile index 5e0bd00a72..5ba85695ce 100644 --- a/Makefile +++ b/Makefile @@ -224,3 +224,11 @@ ifneq ($(SKIP_COMPILE), true) endif docker build -t otelcol-fpm internal/buildscripts/packaging/fpm docker run --rm -v $(CURDIR):/repo -e PACKAGE=$* -e VERSION=$(VERSION) -e ARCH=$(ARCH) -e SMART_AGENT_RELEASE=$(SMART_AGENT_RELEASE) otelcol-fpm + +.PHONY: msi +msi: +ifneq ($(SKIP_COMPILE), true) + $(MAKE) binaries-windows_amd64 +endif + docker build -t msi-builder internal/buildscripts/packaging/msi/msi-builder + docker run --rm -v $(CURDIR):/project -u 0 msi-builder $(VERSION)