Rust connector with docker compose

This example Dockerfile packages example Rust Fluvio project into a connector image.

 

Dockerfile

FROM rust:1.74.1

# Run as the `fluvio` user instead of root
ENV USER=fluvio
RUN useradd --create-home "$USER"
USER $USER
WORKDIR /home/fluvio

# Copy your Rust project and run it
COPY --chown=$USER:$USER Cargo.toml .
COPY --chown=$USER:$USER src ./src
CMD /usr/local/cargo/bin/cargo run

This docker-compose.yml used with docker compose CLI starts our previously built connector image as a local connector

 

docker-compose.yml

version: "3"
services:
 example:
   build: .
   network_mode: "host"
   volumes:
     - $HOME/.fluvio/config:/home/fluvio/.fluvio/config:ro
     - $HOME/.kube:/home/fluvio/.kube:ro
 

Run example

$ docker compose build
$ docker compose run example
 

Example output

[...]
Hello World! - Time is Thu, 10 Nov 2022 02:31:51 +0000
[...]