From 454cd8aae8e41a6163842bd21ad89002c1d591d6 Mon Sep 17 00:00:00 2001 From: Mohammadreza Khani Date: Mon, 9 Dec 2024 00:54:19 +0330 Subject: [PATCH] fix(docker): no foreground task in docker --- Dockerfile.flink | 3 +++ start-cluster.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 start-cluster.sh diff --git a/Dockerfile.flink b/Dockerfile.flink index 72626ca..ebb33cc 100644 --- a/Dockerfile.flink +++ b/Dockerfile.flink @@ -10,5 +10,8 @@ ENV PATH=$FLINK_HOME/bin:$PATH # Expose necessary ports for the Flink UI (JobManager) and job manager EXPOSE 8081 6123 +COPY ./start-cluster.sh /opt/flink/bin/start-cluster.sh +RUN chmod +x /opt/flink/bin/start-cluster.sh + # Command to start Flink JobManager and TaskManager in a mini-cluster setup CMD ["bin/start-cluster.sh"] \ No newline at end of file diff --git a/start-cluster.sh b/start-cluster.sh new file mode 100644 index 0000000..15b56cf --- /dev/null +++ b/start-cluster.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Alternatively, start TaskManager in the foreground if necessary +$FLINK_HOME/bin/taskmanager.sh start + +# Start JobManager in the foreground +$FLINK_HOME/bin/jobmanager.sh start-foreground + +# If you want to submit a job and still keep the cluster alive, use this: +if [[ -n "$FLINK_JOB" ]]; then + echo "Running Flink job: $FLINK_JOB" + $FLINK_HOME/bin/flink run -d $FLINK_JOB +fi + +# Keep the container running +tail -f /dev/null # This will prevent the container from exiting \ No newline at end of file