Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-otelcol circleci job and Makefile updates #261

Merged
merged 3 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 44 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -191,6 +198,7 @@ workflows:
- deb-package
- rpm-package
- windows-msi
- docker-otelcol
filters:
branches:
ignore: /.*/
Expand All @@ -206,6 +214,7 @@ workflows:
- deb-package
- rpm-package
- windows-msi
- docker-otelcol
filters:
branches:
only: main
Expand Down Expand Up @@ -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=fake-realm --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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -461,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
Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -216,6 +219,16 @@ 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

.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)