Java connector with docker compose
This example Dockerfile
packages our example Java Fluvio project into a connector image.
FROM openjdk:11
# Run as the `fluvio` user instead of root
ENV USER=fluvio
RUN useradd --create-home "$USER"
USER $USER
WORKDIR /home/fluvio
# Installing Fluvio CLI for creating topics in example
RUN curl -fsS https://hub.infinyon.cloud/install/install.sh | bash
ENV PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/fluvio/.fluvio/bin
# Copy your Java project and run it
COPY --chown=$USER:$USER fluvio-java .
CMD ./gradlew run
This docker-compose.yml
used with docker compose
CLI starts our previously built connector image as a local connector
version: "3"
services:
example:
build: .
network_mode: "host"
volumes:
- $HOME/.fluvio/config:/home/fluvio/.fluvio/config:ro
- $HOME/.kube:/home/fluvio/.kube:ro
$ docker compose build
$ docker compose run example
[...]
Consumed record, key=0, value=Hello World! - Time is 2:28:01 AM
[...]