Skip to content

Commit fbe91e0

Browse files
ruanhang1993Hang Ruan
andauthored
Update Dockerfiles for 2.2.0 release (#245)
Co-authored-by: Hang Ruan <ruanhang1993@apache.org>
1 parent cfeea17 commit fbe91e0

10 files changed

Lines changed: 796 additions & 4 deletions

File tree

.github/workflows/snapshot.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ jobs:
3737
max-parallel: 1
3838
matrix:
3939
java_version: [8, 11, 17, 21]
40-
flink_version: [ 2.1-SNAPSHOT, 2.0-SNAPSHOT, 1.20-SNAPSHOT, 1.19-SNAPSHOT ]
40+
flink_version: [ 2.2-SNAPSHOT, 2.1-SNAPSHOT, 2.0-SNAPSHOT, 1.20-SNAPSHOT ]
4141
include:
42-
- flink_version: 2.1-SNAPSHOT
42+
- flink_version: 2.2-SNAPSHOT
4343
branch: dev-master
44+
- flink_version: 2.1-SNAPSHOT
45+
branch: dev-2.1
4446
- flink_version: 2.0-SNAPSHOT
4547
branch: dev-2.0
4648
- flink_version: 1.20-SNAPSHOT
4749
branch: dev-1.20
48-
- flink_version: 1.19-SNAPSHOT
49-
branch: dev-1.19
5050
steps:
5151
- uses: actions/checkout@v4
5252
with:
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
###############################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
###############################################################################
18+
19+
FROM eclipse-temurin:11-jre-noble
20+
21+
# Install dependencies
22+
RUN set -ex; \
23+
apt-get update; \
24+
apt-get -y install gpg libsnappy1v5 gettext-base libjemalloc-dev; \
25+
rm -rf /var/lib/apt/lists/*
26+
27+
# Configure Flink version
28+
ENV FLINK_TGZ_URL=https://dlcdn.apache.org/flink/flink-2.2.0/flink-2.2.0-bin-scala_2.12.tgz \
29+
FLINK_ASC_URL=https://downloads.apache.org/flink/flink-2.2.0/flink-2.2.0-bin-scala_2.12.tgz.asc \
30+
GPG_KEY=7BC9FA3EBE7E3DC7CD0EA0454C09617EAF241D76 \
31+
CHECK_GPG=true
32+
33+
# Prepare environment
34+
ENV FLINK_HOME=/opt/flink
35+
ENV PATH=$FLINK_HOME/bin:$PATH
36+
RUN groupadd --system --gid=9999 flink && \
37+
useradd --system --home-dir $FLINK_HOME --uid=9999 --gid=flink flink
38+
WORKDIR $FLINK_HOME
39+
40+
# Install Flink
41+
RUN set -ex; \
42+
wget -nv -O flink.tgz "$FLINK_TGZ_URL"; \
43+
\
44+
if [ "$CHECK_GPG" = "true" ]; then \
45+
wget -nv -O flink.tgz.asc "$FLINK_ASC_URL"; \
46+
export GNUPGHOME="$(mktemp -d)"; \
47+
for server in hkps://keys.openpgp.org $(shuf -e \
48+
keyserver.ubuntu.com \
49+
hkp://keyserver.ubuntu.com:80 \
50+
pgp.mit.edu) ; do \
51+
gpg --batch --keyserver "$server" --recv-keys "$GPG_KEY" && break || : ; \
52+
done && \
53+
gpg --batch --verify flink.tgz.asc flink.tgz; \
54+
gpgconf --kill all; \
55+
rm -rf "$GNUPGHOME" flink.tgz.asc; \
56+
fi; \
57+
\
58+
tar -xf flink.tgz --strip-components=1; \
59+
rm flink.tgz; \
60+
\
61+
chown -R flink:flink .; \
62+
\
63+
# Replace default REST/RPC endpoint bind address to use the container's network interface \
64+
CONF_FILE="${FLINK_HOME}/conf/config.yaml"; \
65+
/bin/bash "$FLINK_HOME/bin/config-parser-utils.sh" "${FLINK_HOME}/conf" "${FLINK_HOME}/bin" "${FLINK_HOME}/lib" \
66+
"-repKV" "rest.address,localhost,0.0.0.0" \
67+
"-repKV" "rest.bind-address,localhost,0.0.0.0" \
68+
"-repKV" "jobmanager.bind-host,localhost,0.0.0.0" \
69+
"-repKV" "taskmanager.bind-host,localhost,0.0.0.0" \
70+
"-rmKV" "taskmanager.host=localhost";
71+
72+
# Configure container
73+
USER flink
74+
COPY docker-entrypoint.sh /
75+
ENTRYPOINT ["/docker-entrypoint.sh"]
76+
EXPOSE 6123 8081
77+
CMD ["help"]
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
#!/usr/bin/env bash
2+
3+
###############################################################################
4+
# Licensed to the Apache Software Foundation (ASF) under one
5+
# or more contributor license agreements. See the NOTICE file
6+
# distributed with this work for additional information
7+
# regarding copyright ownership. The ASF licenses this file
8+
# to you under the Apache License, Version 2.0 (the
9+
# "License"); you may not use this file except in compliance
10+
# with the License. You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
###############################################################################
20+
21+
COMMAND_STANDALONE="standalone-job"
22+
COMMAND_HISTORY_SERVER="history-server"
23+
24+
# If unspecified, the hostname of the container is taken as the JobManager address
25+
JOB_MANAGER_RPC_ADDRESS=${JOB_MANAGER_RPC_ADDRESS:-$(hostname -f)}
26+
CONF_FILE_DIR="${FLINK_HOME}/conf"
27+
28+
check_priv_user() {
29+
if [ $(id -u) == 0 ]; then
30+
echo "WARNING: Running as root user is not recommended. Please use a non-root user to run Flink."
31+
fi
32+
}
33+
34+
copy_plugins_if_required() {
35+
if [ -z "$ENABLE_BUILT_IN_PLUGINS" ]; then
36+
return 0
37+
fi
38+
39+
echo "Enabling required built-in plugins"
40+
for target_plugin in $(echo "$ENABLE_BUILT_IN_PLUGINS" | tr ';' ' '); do
41+
echo "Linking ${target_plugin} to plugin directory"
42+
plugin_name=${target_plugin%.jar}
43+
44+
mkdir -p "${FLINK_HOME}/plugins/${plugin_name}"
45+
if [ ! -e "${FLINK_HOME}/opt/${target_plugin}" ]; then
46+
echo "Plugin ${target_plugin} does not exist. Exiting."
47+
exit 1
48+
else
49+
ln -fs "${FLINK_HOME}/opt/${target_plugin}" "${FLINK_HOME}/plugins/${plugin_name}"
50+
echo "Successfully enabled ${target_plugin}"
51+
fi
52+
done
53+
}
54+
55+
set_config_options() {
56+
local config_parser_script="$FLINK_HOME/bin/config-parser-utils.sh"
57+
local config_dir="$FLINK_HOME/conf"
58+
local bin_dir="$FLINK_HOME/bin"
59+
local lib_dir="$FLINK_HOME/lib"
60+
61+
local config_params=()
62+
63+
while [ $# -gt 0 ]; do
64+
local key="$1"
65+
local value="$2"
66+
67+
config_params+=("-D${key}=${value}")
68+
69+
shift 2
70+
done
71+
72+
if [ "${#config_params[@]}" -gt 0 ]; then
73+
"${config_parser_script}" "${config_dir}" "${bin_dir}" "${lib_dir}" "${config_params[@]}"
74+
fi
75+
}
76+
77+
prepare_configuration() {
78+
local config_options=()
79+
80+
config_options+=("jobmanager.rpc.address" "${JOB_MANAGER_RPC_ADDRESS}")
81+
config_options+=("blob.server.port" "6124")
82+
config_options+=("query.server.port" "6125")
83+
84+
if [ -n "${TASK_MANAGER_NUMBER_OF_TASK_SLOTS}" ]; then
85+
config_options+=("taskmanager.numberOfTaskSlots" "${TASK_MANAGER_NUMBER_OF_TASK_SLOTS}")
86+
fi
87+
88+
if [ ${#config_options[@]} -ne 0 ]; then
89+
set_config_options "${config_options[@]}"
90+
fi
91+
92+
if [ -n "${FLINK_PROPERTIES}" ]; then
93+
process_flink_properties "${FLINK_PROPERTIES}"
94+
fi
95+
}
96+
97+
process_flink_properties() {
98+
local flink_properties_content=$1
99+
local config_options=()
100+
101+
local OLD_IFS="$IFS"
102+
IFS=$'\n'
103+
for prop in $flink_properties_content; do
104+
prop=$(echo $prop | tr -d '[:space:]')
105+
106+
if [ -z "$prop" ]; then
107+
continue
108+
fi
109+
110+
IFS=':' read -r key value <<< "$prop"
111+
112+
value=$(echo $value | envsubst)
113+
114+
config_options+=("$key" "$value")
115+
done
116+
IFS="$OLD_IFS"
117+
118+
if [ ${#config_options[@]} -ne 0 ]; then
119+
set_config_options "${config_options[@]}"
120+
fi
121+
}
122+
123+
maybe_enable_jemalloc() {
124+
if [ "${DISABLE_JEMALLOC:-false}" == "false" ]; then
125+
JEMALLOC_PATH="/usr/lib/$(uname -m)-linux-gnu/libjemalloc.so"
126+
JEMALLOC_FALLBACK="/usr/lib/x86_64-linux-gnu/libjemalloc.so"
127+
if [ -f "$JEMALLOC_PATH" ]; then
128+
export LD_PRELOAD=$LD_PRELOAD:$JEMALLOC_PATH
129+
elif [ -f "$JEMALLOC_FALLBACK" ]; then
130+
export LD_PRELOAD=$LD_PRELOAD:$JEMALLOC_FALLBACK
131+
else
132+
if [ "$JEMALLOC_PATH" = "$JEMALLOC_FALLBACK" ]; then
133+
MSG_PATH=$JEMALLOC_PATH
134+
else
135+
MSG_PATH="$JEMALLOC_PATH and $JEMALLOC_FALLBACK"
136+
fi
137+
echo "WARNING: attempted to load jemalloc from $MSG_PATH but the library couldn't be found. glibc will be used instead."
138+
fi
139+
fi
140+
}
141+
142+
check_priv_user
143+
144+
maybe_enable_jemalloc
145+
146+
copy_plugins_if_required
147+
148+
prepare_configuration
149+
150+
args=("$@")
151+
if [ "$1" = "help" ]; then
152+
printf "Usage: $(basename "$0") (jobmanager|${COMMAND_STANDALONE}|taskmanager|${COMMAND_HISTORY_SERVER})\n"
153+
printf " Or $(basename "$0") help\n\n"
154+
printf "By default, Flink image adopts jemalloc as default memory allocator. This behavior can be disabled by setting the 'DISABLE_JEMALLOC' environment variable to 'true'.\n"
155+
exit 0
156+
elif [ "$1" = "jobmanager" ]; then
157+
args=("${args[@]:1}")
158+
159+
echo "Starting Job Manager"
160+
161+
exec "$FLINK_HOME/bin/jobmanager.sh" start-foreground "${args[@]}"
162+
elif [ "$1" = ${COMMAND_STANDALONE} ]; then
163+
args=("${args[@]:1}")
164+
165+
echo "Starting Job Manager"
166+
167+
exec "$FLINK_HOME/bin/standalone-job.sh" start-foreground "${args[@]}"
168+
elif [ "$1" = ${COMMAND_HISTORY_SERVER} ]; then
169+
args=("${args[@]:1}")
170+
171+
echo "Starting History Server"
172+
173+
exec "$FLINK_HOME/bin/historyserver.sh" start-foreground "${args[@]}"
174+
elif [ "$1" = "taskmanager" ]; then
175+
args=("${args[@]:1}")
176+
177+
echo "Starting Task Manager"
178+
179+
exec "$FLINK_HOME/bin/taskmanager.sh" start-foreground "${args[@]}"
180+
fi
181+
182+
args=("${args[@]}")
183+
184+
# Running command in pass-through mode
185+
exec "${args[@]}"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Tags: 2.2.0-scala_2.12-java11, 2.2-scala_2.12-java11, scala_2.12-java11, 2.2.0-java11, 2.2-java11, java11
2+
Architectures: amd64,arm64v8
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
###############################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
###############################################################################
18+
19+
FROM eclipse-temurin:17-jre-noble
20+
21+
# Install dependencies
22+
RUN set -ex; \
23+
apt-get update; \
24+
apt-get -y install gpg libsnappy1v5 gettext-base libjemalloc-dev; \
25+
rm -rf /var/lib/apt/lists/*
26+
27+
# Configure Flink version
28+
ENV FLINK_TGZ_URL=https://dlcdn.apache.org/flink/flink-2.2.0/flink-2.2.0-bin-scala_2.12.tgz \
29+
FLINK_ASC_URL=https://downloads.apache.org/flink/flink-2.2.0/flink-2.2.0-bin-scala_2.12.tgz.asc \
30+
GPG_KEY=7BC9FA3EBE7E3DC7CD0EA0454C09617EAF241D76 \
31+
CHECK_GPG=true
32+
33+
# Prepare environment
34+
ENV FLINK_HOME=/opt/flink
35+
ENV PATH=$FLINK_HOME/bin:$PATH
36+
RUN groupadd --system --gid=9999 flink && \
37+
useradd --system --home-dir $FLINK_HOME --uid=9999 --gid=flink flink
38+
WORKDIR $FLINK_HOME
39+
40+
# Install Flink
41+
RUN set -ex; \
42+
wget -nv -O flink.tgz "$FLINK_TGZ_URL"; \
43+
\
44+
if [ "$CHECK_GPG" = "true" ]; then \
45+
wget -nv -O flink.tgz.asc "$FLINK_ASC_URL"; \
46+
export GNUPGHOME="$(mktemp -d)"; \
47+
for server in hkps://keys.openpgp.org $(shuf -e \
48+
keyserver.ubuntu.com \
49+
hkp://keyserver.ubuntu.com:80 \
50+
pgp.mit.edu) ; do \
51+
gpg --batch --keyserver "$server" --recv-keys "$GPG_KEY" && break || : ; \
52+
done && \
53+
gpg --batch --verify flink.tgz.asc flink.tgz; \
54+
gpgconf --kill all; \
55+
rm -rf "$GNUPGHOME" flink.tgz.asc; \
56+
fi; \
57+
\
58+
tar -xf flink.tgz --strip-components=1; \
59+
rm flink.tgz; \
60+
\
61+
chown -R flink:flink .; \
62+
\
63+
# Replace default REST/RPC endpoint bind address to use the container's network interface \
64+
CONF_FILE="${FLINK_HOME}/conf/config.yaml"; \
65+
/bin/bash "$FLINK_HOME/bin/config-parser-utils.sh" "${FLINK_HOME}/conf" "${FLINK_HOME}/bin" "${FLINK_HOME}/lib" \
66+
"-repKV" "rest.address,localhost,0.0.0.0" \
67+
"-repKV" "rest.bind-address,localhost,0.0.0.0" \
68+
"-repKV" "jobmanager.bind-host,localhost,0.0.0.0" \
69+
"-repKV" "taskmanager.bind-host,localhost,0.0.0.0" \
70+
"-rmKV" "taskmanager.host=localhost";
71+
72+
# Configure container
73+
USER flink
74+
COPY docker-entrypoint.sh /
75+
ENTRYPOINT ["/docker-entrypoint.sh"]
76+
EXPOSE 6123 8081
77+
CMD ["help"]

0 commit comments

Comments
 (0)