Skip to content

Commit

Permalink
Merge pull request #51 from data-catering/user-id
Browse files Browse the repository at this point in the history
Add in user for kafka services
  • Loading branch information
pflooky authored Jul 15, 2024
2 parents 39b9206 + d59eb6e commit 91fe837
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@
"environment":
- "KAFKA_TOPICS=${KAFKA_TOPICS:-accounts,transactions}"
"image": "confluentinc/confluent-local:${KAFKA_VERSION:-7.6.1}"
"user": "${CURRENT_UID}"
"volumes":
- "./data/kafka/init.sh:/tmp/scripts/init.sh"
"kafka-server":
Expand All @@ -485,6 +486,7 @@
"image": "confluentinc/confluent-local:7.6.1"
"ports":
- "9092:9092"
"user": "${CURRENT_UID}"
"volumes":
- "./data/kafka/persist:/var/lib/kafka/data"
"keycloak":
Expand Down
12 changes: 11 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ usage() {
exit 0
}

set_user() {
if [ -z "$CURRENT_UID" ]
then
current_user="$(id -u):$(id -g)"
export CURRENT_UID="$current_user"
fi
}

connect_to_service() {
if [ -z "$1" ]
then
Expand All @@ -72,6 +80,7 @@ connect_to_service() {
}

shutdown_service() {
set_user
if [ -z "$1" ]; then
echo "Shutting down all services..."
docker-compose -f "$SCRIPT_DIR/docker-compose.yaml" down
Expand Down Expand Up @@ -99,9 +108,10 @@ check_docker_installed() {
}

startup_services() {
set_user
all_services=("$@")
echo -e "${GREEN}Starting up services...${NC}"
docker-compose -f "$SCRIPT_DIR/docker-compose.yaml" up -d "$@"
docker-compose -f "$SCRIPT_DIR/docker-compose.yaml" up -d --quiet-pull "$@"
if [ $? != 0 ]; then
echo -e "${RED}Error: Failed to start up services${NC}"
exit 1
Expand Down

0 comments on commit 91fe837

Please sign in to comment.