Skip to content

Commit 3253d3b

Browse files
authored
feat: build ubi image (#104)
* feat: build ubi image Signed-off-by: Dominik Rosiek <drosiek@sumologic.com> * feat: add License to the image Signed-off-by: Dominik Rosiek <drosiek@sumologic.com> * Update Dockerfile * Apply suggestions from code review --------- Signed-off-by: Dominik Rosiek <drosiek@sumologic.com>
1 parent 80980dc commit 3253d3b

File tree

6 files changed

+102
-16
lines changed

6 files changed

+102
-16
lines changed

.github/workflows/dev_builds.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,19 @@ jobs:
3636
- name: Build and push image to Open Source ECR
3737
run: make build-push-multiplatform
3838

39+
- name: Build and push UBI image to Open Source ECR
40+
run: make build-push-multiplatform \
41+
DOCKERFILE=Dockerfile-ubi \
42+
TAG_SUFFIX=-ubi
43+
3944
- name: Build and push image to Docker Hub
4045
run: |-
4146
make build-push-multiplatform \
4247
REPO_URL=sumologic/kubernetes-setup
48+
49+
- name: Build and push UBI image to Docker Hub
50+
run: |-
51+
make build-push-multiplatform \
52+
REPO_URL=sumologic/kubernetes-setup \
53+
DOCKERFILE=Dockerfile-ubi
54+
TAG_SUFFIX=-ubi

.github/workflows/pull_requests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ jobs:
1212
- uses: actions/checkout@v4
1313
- name: Build setup image
1414
run: make build
15+
- name: Build UBI based setup image
16+
run: make build \
17+
DOCKERFILE=Dockerfile-ubi \
18+
TAG_SUFFIX=-ubi

.github/workflows/release_builds.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Release builds
33
on:
44
push:
55
tags:
6-
- 'v[0-9]+.[0-9]+.[0-9]+'
7-
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
8-
- 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
9-
- 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
8+
- "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"
9+
- "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"
1010

1111
jobs:
1212
setup-image:
@@ -46,8 +46,22 @@ jobs:
4646
- name: Build and push image to Open Source ECR
4747
run: make build-push-multiplatform BUILD_TAG=${{ steps.extract_tag.outputs.tag }}
4848

49+
- name: Build and push UBI image to Open Source ECR
50+
run: make build-push-multiplatform \
51+
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
52+
TAG_SUFFIX=-ubi \
53+
DOCKERFILE=Dockerfile-ubi
54+
4955
- name: Build and push image to Docker Hub
5056
run: |-
5157
make build-push-multiplatform \
5258
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
5359
REPO_URL=sumologic/kubernetes-setup
60+
61+
- name: Build and push UBI image to Docker Hub
62+
run: |-
63+
make build-push-multiplatform \
64+
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
65+
REPO_URL=sumologic/kubernetes-setup \
66+
TAG_SUFFIX=-ubi \
67+
DOCKERFILE=Dockerfile-ubi

Dockerfile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ RUN apk add --no-cache \
1212
jq \
1313
git \
1414
&& apk upgrade \
15-
# ping group has a conflicting id: 999 so delete it
16-
&& delgroup ping \
17-
&& addgroup -g 999 setup \
18-
&& adduser -u 999 -D -G setup setup \
15+
&& addgroup -g 1000 setup \
16+
&& adduser -u 1000 -D -G setup setup \
1917
&& mkdir /terraform /scripts /monitors \
2018
&& chown -R setup:setup /terraform /scripts /monitors
2119

@@ -35,7 +33,7 @@ RUN cd /monitors/ \
3533
&& terraform init -input=false || terraform init -input=false -upgrade \
3634
&& rm -rf terraform-sumologic-sumo-logic-monitor
3735

38-
ARG BUILD_TAG=latest
39-
ENV TAG=$BUILD_TAG
36+
ARG BUILD_TAG=latest
37+
ENV TAG=$BUILD_TAG
4038

4139
WORKDIR /terraform/

Dockerfile-ubi

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
FROM hashicorp/terraform:1.8.4 as terraform
2+
3+
FROM registry.access.redhat.com/ubi8/ubi:8.4
4+
5+
ENV SUMMARY="UBI based Sumo Logic Kubernetes Setup" \
6+
DESCRIPTION="UBI based setup image for the Sumo Logic Kubernetes Collection"
7+
8+
ENV COLLECTION_VERSION=v4.6.1
9+
ENV MONITORS_VERSION=v1.2.4
10+
ARG TARGETPLATFORM
11+
12+
RUN dnf update -y \
13+
&& dnf install -y \
14+
bash \
15+
curl \
16+
jq \
17+
git \
18+
&& dnf clean all \
19+
&& groupadd -g 1000 setup \
20+
&& adduser -u 1000 -g setup setup \
21+
&& mkdir /terraform /scripts /monitors \
22+
&& chown -R setup:setup /terraform /scripts /monitors
23+
24+
COPY --from=terraform /bin/terraform /usr/local/bin/terraform
25+
26+
USER setup
27+
RUN cd /terraform/ \
28+
&& curl -O https://raw.githubusercontent.com/SumoLogic/sumologic-kubernetes-collection/${COLLECTION_VERSION}/deploy/helm/sumologic/conf/setup/main.tf \
29+
&& terraform init \
30+
&& rm main.tf
31+
RUN cd /monitors/ \
32+
&& git clone https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor.git \
33+
&& cd terraform-sumologic-sumo-logic-monitor \
34+
&& git checkout ${MONITORS_VERSION} \
35+
&& cd .. \
36+
&& cp terraform-sumologic-sumo-logic-monitor/monitor_packages/kubernetes/* . \
37+
&& terraform init -input=false || terraform init -input=false -upgrade \
38+
&& rm -rf terraform-sumologic-sumo-logic-monitor
39+
40+
ARG BUILD_TAG=latest
41+
ENV TAG=$BUILD_TAG
42+
43+
LABEL name="Sumo Logic Kubernetes Setup" \
44+
vendor="Sumo Logic" \
45+
version="${BUILD_TAG}" \
46+
release="1" \
47+
summary="$SUMMARY" \
48+
description="$DESCRIPTION" \
49+
maintainer="opensource-collection-team@sumologic.com"
50+
51+
ADD LICENSE \
52+
/licenses/LICENSE
53+
54+
WORKDIR /terraform/

Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,32 @@ BUILD_TAG ?= latest
22
IMAGE_NAME = kubernetes-setup
33
ECR_URL = public.ecr.aws/sumologic
44
REPO_URL = $(ECR_URL)/$(IMAGE_NAME)
5+
DOCKERFILE = Dockerfile
6+
TAG_SUFFIX = ""
57

68
build:
79
DOCKER_BUILDKIT=1 docker build \
8-
--build-arg BUILD_TAG=$(BUILD_TAG) \
10+
-f $(DOCKERFILE) \
11+
--build-arg BUILD_TAG=$(BUILD_TAG)$(TAG_SUFFIX) \
912
--build-arg BUILDKIT_INLINE_CACHE=1 \
1013
--cache-from $(REPO_URL):latest \
11-
--tag $(IMAGE_NAME):$(BUILD_TAG) \
14+
--tag $(IMAGE_NAME):$(BUILD_TAG)$(TAG_SUFFIX) \
1215
.
1316

1417
push:
15-
docker tag $(IMAGE_NAME):$(BUILD_TAG) $(REPO_URL):$(BUILD_TAG)
16-
docker push $(REPO_URL):$(BUILD_TAG)
18+
docker tag $(IMAGE_NAME):$(BUILD_TAG)$(TAG_SUFFIX) $(REPO_URL):$(BUILD_TAG)$(TAG_SUFFIX)
19+
docker push $(REPO_URL):$(BUILD_TAG)$(TAG_SUFFIX)
1720

1821
login:
1922
aws ecr-public get-login-password --region us-east-1 \
2023
| docker login --username AWS --password-stdin $(ECR_URL)
2124

2225
build-push-multiplatform:
2326
docker buildx build \
27+
-f $(DOCKERFILE) \
2428
--push \
2529
--platform linux/amd64,linux/arm/v7,linux/arm64 \
26-
--build-arg BUILD_TAG=$(BUILD_TAG) \
27-
--tag $(REPO_URL):$(BUILD_TAG) \
30+
--build-arg BUILD_TAG=$(BUILD_TAG)$(TAG_SUFFIX) \
31+
--tag $(REPO_URL):$(BUILD_TAG)$(TAG_SUFFIX) \
2832
.
2933

0 commit comments

Comments
 (0)