Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To document or provide an script easier to run docker container images of the application #4275

Closed
2 tasks done
adrinerandrade opened this issue Oct 5, 2023 · 1 comment
Closed
2 tasks done
Labels
status/triage Issues pending maintainers triage type/feature A new feature

Comments

@adrinerandrade
Copy link

Issue submitter TODO list

  • I've searched for an already existing issues here
  • I'm running a supported version of the application which is listed here and the feature is not present there

Is your proposal related to a problem?

I think that we can make easier to configure and run an application container in our local environment. Here's an ideia about providing a shell command with basic configurations and easier way to start using the app.

Describe the feature you're interested in

I created this script to run the containers easily and it was helpful to me, so I'm sharing here to maybe help another developers. If you guys think it will be good to document it or incorporate in the repository, it's your decision.

Script:

#!/bin/bash

# Define a function to display usage information
function usage() {
  echo "Usage: $0 [-n container_name] [-p host_port] [-c cluster_name] [-b bootstrap_servers] [-c cluster_name -b bootstrap_servers...] [-h]"
  echo "  -n  Specify the name of the Docker container (default: kafka-ui)"
  echo "  -p  Specify the host port to expose (default: 8080)"
  echo "  -c  Specify the name of a Kafka cluster (required)"
  echo "  -b  Specify the comma-separated list of bootstrap servers for the Kafka cluster (required)"
  echo "  -h  Display this help message"
  exit 1
}

# Parse command-line arguments
while getopts "n:p:c:b:h" opt; do
  case $opt in
    n)
      container_name="$OPTARG"
      ;;
    p)
      host_port="$OPTARG"
      ;;
    c)
      cluster_name+=("$OPTARG")
      ;;
    b)
      bootstrap_servers+=("$OPTARG")
      ;;
    h)
      usage
      ;;
    \?)
      echo "Invalid option: -$OPTARG" >&2
      usage
      ;;
    :)
      echo "Option -$OPTARG requires an argument." >&2
      usage
      ;;
  esac
done

# Verify that required arguments are specified
if [ ${#cluster_name[@]} -eq 0 ] || [ ${#bootstrap_servers[@]} -eq 0 ]; then
  echo "Error: -c and -b must be specified at least once." >&2
  usage
fi

# Set default values if not specified
container_name=${container_name:-"kafka-ui"}
host_port=${host_port:-"8080"}

# Build a list of cluster configurations
i=0
while [ $i -lt ${#cluster_name[@]} ] && [ $i -lt ${#bootstrap_servers[@]} ]; do
  clusters_args="$clusters_args -e KAFKA_CLUSTERS_${i}_NAME=${cluster_name[$i]} -e KAFKA_CLUSTERS_${i}_BOOTSTRAP_SERVERS=${bootstrap_servers[$i]}"
  i=$((i+1))
done

echo "${clusters_args}"

# Run the docker command
sudo docker run -d \
  --name $container_name \
  -p $host_port:8080 \
  $clusters_args \
  provectuslabs/kafka-ui

Usage:

./start-kafka-ui.sh -h

Usage: ./start-kafka-ui.sh [-n container_name] [-p host_port] [-c cluster_name] [-b bootstrap_servers] [-c cluster_name -b bootstrap_servers...] [-h]
  -n  Specify the name of the Docker container (default: kafka-ui)
  -p  Specify the host port to expose (default: 8080)
  -c  Specify the name of a Kafka cluster (required)
  -b  Specify the comma-separated list of bootstrap servers for the Kafka cluster (required)

Describe alternatives you've considered

No response

Version you're running

v0.7.1

Additional context

No response

@adrinerandrade adrinerandrade added status/triage Issues pending maintainers triage type/feature A new feature labels Oct 5, 2023
@github-actions
Copy link

github-actions bot commented Oct 5, 2023

Hello there adrinerandrade! 👋

Thank you and congratulations 🎉 for opening your very first issue in this project! 💖

In case you want to claim this issue, please comment down below! We will try to get back to you as soon as we can. 👀

@adrinerandrade adrinerandrade closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/triage Issues pending maintainers triage type/feature A new feature
Projects
None yet
Development

No branches or pull requests

1 participant