Skip to content

Commit

Permalink
feat: build UBI-based image (#1440)
Browse files Browse the repository at this point in the history
* add ubi release pipeline

* add ubi dev pipeline

* add dockerfile

* fix repo url

* update image name

* temporarily disable windows builds

* fix endline

* fix license

* working dockerfile

* clean

* fix newline

* add suffix to regular tag

* fix build tag name

* add changelog

* fix fips build name

* remove redundant lines from Dockerfile

* update dockerfile
  • Loading branch information
aboguszewski-sumo committed Feb 20, 2024
1 parent 35a1225 commit 28d1a7f
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 5 deletions.
1 change: 1 addition & 0 deletions .changelog/1440.changed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ci: build ubi-based images
19 changes: 17 additions & 2 deletions .github/workflows/dev_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
run: |
cp otelcol-sumo-fips-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-multiplatform-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }}-fips \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORM=${{ matrix.arch_os }} \
BUILD_TYPE_SUFFIX="-fips"
Expand All @@ -175,6 +175,14 @@ jobs:
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORM=${{ matrix.arch_os }}
- name: Build and push UBI-based image to Open Source ECR
run: |
cp otelcol-sumo-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-ubi-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORM=${{ matrix.arch_os }} \
BUILD_TYPE_SUFFIX="-ubi"
push-docker-manifest:
name: Push joint container manifest
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -209,7 +217,7 @@ jobs:
- name: Push joint FIPS container manifest for all platforms to Open Source ECR
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }}-fips \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORMS="linux/amd64" \
BUILD_TYPE_SUFFIX="-fips"
Expand All @@ -219,6 +227,13 @@ jobs:
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORMS="linux/amd64 linux/arm64"
- name: Push joint UBI-based container manifest for all platforms to Open Source ECR
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORMS="linux/amd64" \
BUILD_TYPE_SUFFIX="-ubi"
package-msi:
name: Package MSI
runs-on: windows-2019
Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/release_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ jobs:
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORM=${{ matrix.arch_os }}
- name: Build and push UBI-based image to Open Source ECR
if: matrix.arch_os == 'linux_amd64'
run: |
cp artifacts/${{ steps.set_filename.outputs.filename }} otelcol-sumo
make build-push-container-ubi \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }}-ubi \
PLATFORM=${{ matrix.arch_os }}
BUILD_TYPE_SUFFIX="-ubi"
push-docker-manifest:
name: Push joint container manifest
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -404,7 +413,7 @@ jobs:
- name: Push joint FIPS container manifest for all platforms to Open Source ECR
run: |
make push-container-manifest \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }}-fips \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORMS="linux/amd64" \
BUILD_TYPE_SUFFIX="-fips"
Expand All @@ -414,6 +423,13 @@ jobs:
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORMS="linux/amd64 linux/arm64"
- name: Push joint UBI-based container manifest for all platforms to Open Source ECR
run: |
make push-container-manifest \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORMS="linux/amd64"
BUILD_TYPE_SUFFIX="-ubi"
package-msi:
name: Package MSI
runs-on: windows-2019
Expand Down
33 changes: 33 additions & 0 deletions Dockerfile_ubi
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ARG BUILD_TAG
ARG REPO_URL=sumologic-otel-collector
ARG BUILD_ARCH

## Build RedHat compliant image
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9

ENV SUMMARY="UBI based sumologic-otel-collector" \
DESCRIPTION="Sumo Logic Distribution for OpenTelemetry Collector is a Sumo Logic-supported distribution of the OpenTelemetry Collector. It is a single agent to send logs, metrics and traces to Sumo Logic."

LABEL name="sumologic-otel-collector" \
vendor="Sumo Logic" \
version="$BUILD_TAG" \
release="0" \
summary="$SUMMARY" \
description="$DESCRIPTION" \
io.k8s.description="$DESCRIPTION" \
maintainer="collection@sumologic.com"

ADD https://raw.githubusercontent.com/SumoLogic/sumologic-otel-collector/main/LICENSE \
/licenses/LICENSE

RUN microdnf update && microdnf install systemd && microdnf clean all

ENV TAG $BUILD_TAG
ARG USER_UID=10001
USER ${USER_UID}
ENV HOME /etc/otel/

COPY otelcol-sumo /

ENTRYPOINT ["/otelcol-sumo"]
CMD ["--config", "/etc/otel/config.yaml"]
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ OPENSOURCE_REPO_URL = $(OPENSOURCE_ECR_URL)/$(IMAGE_NAME)
OPENSOURCE_REPO_URL_DEV = $(OPENSOURCE_ECR_URL)/$(IMAGE_NAME_DEV)
REPO_URL = $(OPENSOURCE_REPO_URL)

DOCKERFILE = Dockerfile

.PHONY: _build
_build:
DOCKER_BUILDKIT=1 docker build \
Expand Down Expand Up @@ -282,6 +284,10 @@ build-push-container-multiplatform-dev: build-push-container-multiplatform
push-container-manifest-dev: REPO_URL = "$(OPENSOURCE_REPO_URL_DEV)"
push-container-manifest-dev: push-container-manifest

.PHONY: build-push-container-ubi
build-push-container-ubi-dev: REPO_URL = "$(OPENSOURCE_REPO_URL_DEV)"
build-push-container-ubi-dev: build-push-container-ubi

#-------------------------------------------------------------------------------

# release
Expand All @@ -290,7 +296,7 @@ push-container-manifest-dev: push-container-manifest
_build-container-multiplatform:
BUILD_TAG="$(BUILD_TAG)" \
REPO_URL="$(REPO_URL)" \
DOCKERFILE="Dockerfile" \
DOCKERFILE="$(DOCKERFILE)" \
PLATFORM="$(PLATFORM)" \
./ci/build-push-multiplatform.sh $(PUSH)

Expand All @@ -301,6 +307,11 @@ build-container-multiplatform: _build-container-multiplatform
build-push-container-multiplatform: PUSH = --push
build-push-container-multiplatform: _build-container-multiplatform

.PHONY: build-push-container-ubi
build-push-container-ubi: PUSH = --push
build-push-container-ubi: DOCKERFILE = Dockerfile_ubi
build-push-container-ubi: _build-container-multiplatform

.PHONY: test-built-image
test-built-image:
docker run --rm "$(REPO_URL):$(BUILD_TAG)" --version
Expand Down
2 changes: 1 addition & 1 deletion ci/build-push-multiplatform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function build_push() {
esac

local TAG
readonly TAG="${REPO_URL}:${BUILD_TAG}-${BUILD_ARCH}"
readonly TAG="${REPO_URL}:${BUILD_TAG}${BUILD_TYPE_SUFFIX}-${BUILD_ARCH}"
local LATEST_TAG
readonly LATEST_TAG="${REPO_URL}:latest${BUILD_TYPE_SUFFIX}-${BUILD_ARCH}"

Expand Down

0 comments on commit 28d1a7f

Please sign in to comment.