Skip to content

Commit 96932fa

Browse files
Leonid Ryzhykryzhyk
authored andcommitted
Custom Kafka Connect docker image.
In preparation for adding support for Snowflake output connector, we replace the pre-built Kafka Connect image from Debezium with a custom one that adds Snowflake connector classes to the image. There are a couple of Kafka Connect base images we could build upon, including one from Confluent, but that one seems to assume Apache Kafka and may not work well with Redpanda (first thing it did when I tried it is complain about not having Zookeeper around :) ). In addition, we want the image to contain Debezium connectors, so building on the Debezium image from RedHat seemed like a good choice. This commit: 1. Adds a Kafka Connect container build step to Earthfile 2. Adds identical instructions for building the connector to Dockerfile 3. Sets up github CI to build the container along with other Feldera containers. While I was at it, I also added a trigger to the `containers.yml` to allow triggering the container build workflow manually. This is useful if we want to build the containers without waiting for the cronjob. Signed-off-by: Leonid Ryzhyk <leonid@feldera.com>
1 parent 1a3a7c3 commit 96932fa

4 files changed

Lines changed: 52 additions & 7 deletions

File tree

.github/workflows/containers.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ on:
33
- cron: '0 0 * * *'
44
release:
55
types: [published]
6+
workflow_dispatch:
67

78
env:
89
REGISTRY: ghcr.io
910
PIPELINE_MANAGER_IMAGE: ghcr.io/${{ github.repository_owner }}/pipeline-manager
1011
DEMO_IMAGE: ghcr.io/${{ github.repository_owner }}/demo-container
12+
KAFKA_CONNECT_IMAGE: ghcr.io/${{ github.repository_owner }}/kafka-connect
1113

1214
jobs:
1315
build-and-push-image:
@@ -43,6 +45,19 @@ jobs:
4345
tags: |
4446
type=semver,pattern={{version}}
4547
48+
- name: Docker meta (kafka-connect)
49+
id: meta_kafka_connect
50+
uses: docker/metadata-action@v4
51+
with:
52+
images: ${{ env.KAFKA_CONNECT_IMAGE }}
53+
tags: |
54+
type=semver,pattern={{version}}
55+
56+
- name: Build Kafka Connect container
57+
run: |
58+
cd deploy && \
59+
docker build --target kafka-connect -t ${{ env.KAFKA_CONNECT_IMAGE }} .
60+
4661
- name: Run integration tests
4762
run: |
4863
cd deploy && \
@@ -71,7 +86,7 @@ jobs:
7186
# Push untagged images when the workflow is not triggered by a release
7287
- name: Push containers
7388
if: github.event_name != 'release'
74-
run: docker push ${{ env.PIPELINE_MANAGER_IMAGE }} && docker push ${{ env.DEMO_IMAGE }}
89+
run: docker push ${{ env.PIPELINE_MANAGER_IMAGE }} && docker push ${{ env.DEMO_IMAGE }} && docker push ${{ env.KAFKA_CONNECT_IMAGE }}
7590

7691
# Tagged DBSP image
7792
- name: Push (pipeline-manager)
@@ -96,6 +111,18 @@ jobs:
96111
tags: ${{ steps.meta_demo.outputs.tags }}
97112
labels: ${{ steps.meta_demo.outputs.labels }}
98113

114+
# Tagged Kafka Connect image
115+
- name: Push (kafka-connect)
116+
uses: docker/build-push-action@v4
117+
if: github.event_name == 'release'
118+
with:
119+
context: .
120+
file: deploy/Dockerfile
121+
target: kafka-connect
122+
push: true
123+
tags: ${{ steps.meta_kafka_connect.outputs.tags }}
124+
labels: ${{ steps.meta_kafka_connect.outputs.labels }}
125+
99126
- uses: actions/delete-package-versions@v4
100127
with:
101128
package-name: pipeline-manager

Earthfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ build-pipeline-manager-container:
514514
COPY sql-to-dbsp-compiler/temp /database-stream-processor/sql-to-dbsp-compiler/temp
515515
RUN ./pipeline-manager --bind-address=0.0.0.0 --api-server-working-directory=/working-dir --compiler-working-directory=/working-dir --runner-working-directory=/working-dir --sql-compiler-home=/database-stream-processor/sql-to-dbsp-compiler --dbsp-override-path=/database-stream-processor --precompile
516516
ENTRYPOINT ["./pipeline-manager", "--bind-address=0.0.0.0", "--api-server-working-directory=/working-dir", "--compiler-working-directory=/working-dir", "--runner-working-directory=/working-dir", "--sql-compiler-home=/database-stream-processor/sql-to-dbsp-compiler", "--dbsp-override-path=/database-stream-processor"]
517-
SAVE IMAGE ghcr.io/feldera/pipeline-manager
518517

519518
# TODO: mirrors the Dockerfile. See note above.
520519
build-demo-container:
@@ -530,7 +529,9 @@ build-demo-container:
530529
COPY +install-python/bin /root/.local/bin
531530
COPY demo demo
532531
CMD bash
533-
SAVE IMAGE ghcr.io/feldera/demo-container
532+
533+
build-kafka-connect-container:
534+
FROM DOCKERFILE -f deploy/Dockerfile --target kafka-connect .
534535

535536
test-docker-compose:
536537
FROM earthly/dind:alpine
@@ -550,10 +551,10 @@ test-debezium:
550551
ENV FELDERA_VERSION=latest
551552
WITH DOCKER --pull postgres \
552553
--pull docker.redpanda.com/vectorized/redpanda:v23.2.3 \
553-
--pull debezium/connect:2.3 \
554554
--pull debezium/example-mysql:2.3 \
555555
--load ghcr.io/feldera/pipeline-manager:latest=+build-pipeline-manager-container \
556-
--load ghcr.io/feldera/demo-container:latest=+build-demo-container
556+
--load ghcr.io/feldera/demo-container:latest=+build-demo-container \
557+
--load ghcr.io/feldera/kafka-connect:latest=+build-kafka-connect-container
557558
RUN COMPOSE_HTTP_TIMEOUT=120 RUST_LOG=debug,tokio_postgres=info docker-compose -f docker-compose.yml -f docker-compose-debezium.yml --profile debezium up --force-recreate --exit-code-from debezium-demo
558559
END
559560

deploy/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ RUN apt update && apt install pkg-config \
167167
&& apt remove python3-pip unzip pkg-config -y && apt autoremove -y
168168
CMD bash
169169

170+
# Kafka connect with all Debezium connectors + the Snowflake connector.
171+
FROM debezium/connect:2.3 AS kafka-connect
172+
RUN mkdir /kafka/connect/snowflake-kafka-connector
173+
RUN cd /kafka/connect/snowflake-kafka-connector \
174+
&& curl -LO https://repo1.maven.org/maven2/com/snowflake/snowflake-kafka-connector/2.1.0/snowflake-kafka-connector-2.1.0.jar \
175+
&& curl -LO https://repo1.maven.org/maven2/org/bouncycastle/bc-fips/1.0.1/bc-fips-1.0.1.jar \
176+
&& curl -LO https://repo1.maven.org/maven2/org/bouncycastle/bcpkix-fips/1.0.3/bcpkix-fips-1.0.3.jar
170177

171178
# By default, only build the release version
172179
FROM release

deploy/docker-compose-debezium.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
# Kafka connect.
55
# TODO: add a healthcheck to this container.
66
connect:
7-
image: debezium/connect:2.3
7+
image: ghcr.io/feldera/kafka-connect:${FELDERA_VERSION:-0.1.6}
88
depends_on:
99
redpanda:
1010
condition: service_healthy
@@ -28,7 +28,17 @@ services:
2828
MYSQL_USER: mysqluser
2929
MYSQL_PASSWORD: mysqlpw
3030
healthcheck:
31-
test: ["CMD", "mysqladmin" , "-u", "$$MYSQL_USER", "-p$$MYSQL_PASSWORD" ,"ping", "-h", "localhost"]
31+
test:
32+
[
33+
"CMD",
34+
"mysqladmin",
35+
"-u",
36+
"$$MYSQL_USER",
37+
"-p$$MYSQL_PASSWORD",
38+
"ping",
39+
"-h",
40+
"localhost"
41+
]
3242
interval: 5s
3343
timeout: 20s
3444
# MySQL can be _very_ slow to start.

0 commit comments

Comments
 (0)