Skip to content

Commit

Permalink
feat: build ubi image
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Rosiek <[email protected]>
  • Loading branch information
Dominik Rosiek committed May 27, 2024
1 parent 80980dc commit c4c9047
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 14 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/dev_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,19 @@ jobs:
- name: Build and push image to Open Source ECR
run: make build-push-multiplatform

- name: Build and push UBI image to Open Source ECR
run: make build-push-multiplatform \
DOCKERFILE=Dockerfile-ubi \
TAG_SUFFIX=-ubi

- name: Build and push image to Docker Hub
run: |-
make build-push-multiplatform \
REPO_URL=sumologic/kubernetes-setup
- name: Build and push UBI image to Docker Hub
run: |-
make build-push-multiplatform \
REPO_URL=sumologic/kubernetes-setup \
DOCKERFILE=Dockerfile-ubi
TAG_SUFFIX=-ubi
22 changes: 18 additions & 4 deletions .github/workflows/release_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Release builds
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"

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

- name: Build and push UBI image to Open Source ECR
run: make build-push-multiplatform \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
TAG_SUFFIX=-ubi \
DOCKERFILE=Dockerfile-ubi

- name: Build and push image to Docker Hub
run: |-
make build-push-multiplatform \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
REPO_URL=sumologic/kubernetes-setup
- name: Build and push UBI image to Docker Hub
run: |-
make build-push-multiplatform \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
REPO_URL=sumologic/kubernetes-setup \
TAG_SUFFIX=-ubi \
DOCKERFILE=Dockerfile-ubi
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ RUN apk add --no-cache \
jq \
git \
&& apk upgrade \
# ping group has a conflicting id: 999 so delete it
&& delgroup ping \
&& addgroup -g 999 setup \
&& adduser -u 999 -D -G setup setup \
&& addgroup -g 1000 setup \
&& adduser -u 1000 -D -G setup setup \
&& mkdir /terraform /scripts /monitors \
&& chown -R setup:setup /terraform /scripts /monitors

Expand Down
40 changes: 40 additions & 0 deletions Dockerfile-ubi
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM hashicorp/terraform:1.8.4 as terraform

FROM registry.access.redhat.com/ubi8/ubi:8.4

ENV COLLECTION_VERSION=v4.6.1
ENV MONITORS_VERSION=v1.2.4
ARG TARGETPLATFORM

RUN dnf update -y \
&& dnf install -y \
bash \
curl \
jq \
git \
&& dnf clean all \
&& groupadd -g 1000 setup \
&& adduser -u 1000 -g setup setup \
&& mkdir /terraform /scripts /monitors \
&& chown -R setup:setup /terraform /scripts /monitors

COPY --from=terraform /bin/terraform /usr/local/bin/terraform

USER setup
RUN cd /terraform/ \
&& curl -O https://raw.githubusercontent.com/SumoLogic/sumologic-kubernetes-collection/${COLLECTION_VERSION}/deploy/helm/sumologic/conf/setup/main.tf \
&& terraform init \
&& rm main.tf
RUN cd /monitors/ \
&& git clone https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor.git \
&& cd terraform-sumologic-sumo-logic-monitor \
&& git checkout ${MONITORS_VERSION} \
&& cd .. \
&& cp terraform-sumologic-sumo-logic-monitor/monitor_packages/kubernetes/* . \
&& terraform init -input=false || terraform init -input=false -upgrade \
&& rm -rf terraform-sumologic-sumo-logic-monitor

ARG BUILD_TAG=latest
ENV TAG=$BUILD_TAG

WORKDIR /terraform/
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@ BUILD_TAG ?= latest
IMAGE_NAME = kubernetes-setup
ECR_URL = public.ecr.aws/sumologic
REPO_URL = $(ECR_URL)/$(IMAGE_NAME)
DOCKERFILE = Dockerfile
TAG_SUFFIX = ""

build:
DOCKER_BUILDKIT=1 docker build \
--build-arg BUILD_TAG=$(BUILD_TAG) \
-f $(DOCKERFILE) \
--build-arg BUILD_TAG=$(BUILD_TAG)$(TAG_SUFFIX) \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $(REPO_URL):latest \
--tag $(IMAGE_NAME):$(BUILD_TAG) \
--tag $(IMAGE_NAME):$(BUILD_TAG)$(TAG_SUFFIX) \
.

push:
docker tag $(IMAGE_NAME):$(BUILD_TAG) $(REPO_URL):$(BUILD_TAG)
docker push $(REPO_URL):$(BUILD_TAG)
docker tag $(IMAGE_NAME):$(BUILD_TAG)$(TAG_SUFFIX) $(REPO_URL):$(BUILD_TAG)$(TAG_SUFFIX)
docker push $(REPO_URL):$(BUILD_TAG)$(TAG_SUFFIX)

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

build-push-multiplatform:
docker buildx build \
-f $(DOCKERFILE) \
--push \
--platform linux/amd64,linux/arm/v7,linux/arm64 \
--build-arg BUILD_TAG=$(BUILD_TAG) \
--tag $(REPO_URL):$(BUILD_TAG) \
--build-arg BUILD_TAG=$(BUILD_TAG)$(TAG_SUFFIX) \
--tag $(REPO_URL):$(BUILD_TAG)$(TAG_SUFFIX) \
.

0 comments on commit c4c9047

Please sign in to comment.