Skip to content

Commit

Permalink
[aiven] feat: add docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
jeqo committed Feb 6, 2024
1 parent 5c79a79 commit 2510b09
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
##
# Copyright 2023 Aiven Oy
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##
# Kafka 3.4.x
FROM confluentinc/cp-kafka:7.4.0

ARG _SCALA_VERSION
ARG _KAFKA_VERSION
ENV _KAFKA_FULL_VERSION "kafka_${_SCALA_VERSION}-${_KAFKA_VERSION}"

USER root
COPY core/build/distributions/${_KAFKA_FULL_VERSION}.tgz /
RUN cd / \
&& tar -xf ${_KAFKA_FULL_VERSION}.tgz \
&& rm -r /usr/share/java/kafka/* \
&& cp /${_KAFKA_FULL_VERSION}/libs/* /usr/share/java/kafka/ \
&& ln -s /usr/share/java/kafka/${_KAFKA_FULL_VERSION}.jar /usr/share/java/kafka/kafka.jar \
&& rm -r /${_KAFKA_FULL_VERSION}.tgz /${_KAFKA_FULL_VERSION}

# Add test jars with local implementations.
COPY clients/build/libs/kafka-clients-${_KAFKA_VERSION}-test.jar /usr/share/java/kafka/
COPY storage/build/libs/kafka-storage-${_KAFKA_VERSION}-test.jar /usr/share/java/kafka/
COPY storage/api/build/libs/kafka-storage-api-${_KAFKA_VERSION}-test.jar /usr/share/java/kafka/

# Restore the user.
USER appuser
48 changes: 48 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
##
# Copyright 2023 Aiven Oy
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##
SCALA_VERSION := $(shell grep -o -E '^scalaVersion=[0-9]+\.[0-9]+\.[0-9]+' gradle.properties | cut -c14-)
SCALA_MAJOR_VERSION := $(shell grep -o -E '^scalaVersion=[0-9]+\.[0-9]+' gradle.properties | cut -c14-)
KAFKA_VERSION := $(shell grep -o -E '^version=[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)?' gradle.properties | cut -c9-)
IMAGE_NAME=aivenoy/kafka

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
IMAGE_TAG := $(subst /,_,$(BRANCH))

.PHONY: all build clean

all: clean build

clean:
./gradlew clean

build: core/build/distributions/kafka_$(SCALA_VERSION)-$(KAFKA_VERSION).tgz

core/build/distributions/kafka_$(SCALA_VERSION)-$(KAFKA_VERSION).tgz:
echo "Version: $(KAFKA_VERSION)-$(SCALA_VERSION)"
./gradlew -PscalaVersion=$(SCALA_VERSION) testJar releaseTarGz

.PHONY: docker_image
docker_image: build
docker build . \
--build-arg _SCALA_VERSION=$(SCALA_MAJOR_VERSION) \
--build-arg _KAFKA_VERSION=$(KAFKA_VERSION) \
-t $(IMAGE_NAME):$(IMAGE_TAG)

.PHONY: docker_push
docker_push:
docker push $(IMAGE_NAME):$(IMAGE_TAG)

# TODO publish docker images

0 comments on commit 2510b09

Please sign in to comment.