Skip to content

Commit d32c85b

Browse files
committed
Update Dockerfiles for 2.0.0 release
1 parent e2765a6 commit d32c85b

File tree

7 files changed

+296
-8
lines changed

7 files changed

+296
-8
lines changed

2.0/scala_2.12-java11-ubuntu/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ RUN set -ex; \
4444
gosu nobody true
4545

4646
# Configure Flink version
47-
ENV FLINK_TGZ_URL=https://dlcdn.apache.org/flink/flink-2.0-preview1/flink-2.0-preview1-bin-scala_2.12.tgz \
48-
FLINK_ASC_URL=https://downloads.apache.org/flink/flink-2.0-preview1/flink-2.0-preview1-bin-scala_2.12.tgz.asc \
49-
GPG_KEY=8D56AE6E7082699A4870750EA4E8C4C05EE6861F \
47+
ENV FLINK_TGZ_URL=https://dlcdn.apache.org/flink/flink-2.0.0/flink-2.0.0-bin-scala_2.12.tgz \
48+
FLINK_ASC_URL=https://downloads.apache.org/flink/flink-2.0.0/flink-2.0.0-bin-scala_2.12.tgz.asc \
49+
GPG_KEY=F8E419AA0B60C28879E876859DFF40967ABFC5A4 \
5050
CHECK_GPG=true
5151

5252
# Prepare environment
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Tags: 2.0-preview1-scala_2.12-java11, 2.0-scala_2.12-java11, scala_2.12-java11, 2.0-preview1-scala_2.12, 2.0-scala_2.12, scala_2.12, 2.0-preview1-java11, 2.0-java11, java11, 2.0-preview1, 2.0, latest
1+
Tags: 2.0.0-scala_2.12-java11, 2.0-scala_2.12-java11, scala_2.12-java11, 2.0.0-java11, 2.0-java11, java11
22
Architectures: amd64,arm64v8

2.0/scala_2.12-java17-ubuntu/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ RUN set -ex; \
4444
gosu nobody true
4545

4646
# Configure Flink version
47-
ENV FLINK_TGZ_URL=https://dlcdn.apache.org/flink/flink-2.0-preview1/flink-2.0-preview1-bin-scala_2.12.tgz \
48-
FLINK_ASC_URL=https://downloads.apache.org/flink/flink-2.0-preview1/flink-2.0-preview1-bin-scala_2.12.tgz.asc \
49-
GPG_KEY=8D56AE6E7082699A4870750EA4E8C4C05EE6861F \
47+
ENV FLINK_TGZ_URL=https://dlcdn.apache.org/flink/flink-2.0.0/flink-2.0.0-bin-scala_2.12.tgz \
48+
FLINK_ASC_URL=https://downloads.apache.org/flink/flink-2.0.0/flink-2.0.0-bin-scala_2.12.tgz.asc \
49+
GPG_KEY=F8E419AA0B60C28879E876859DFF40967ABFC5A4 \
5050
CHECK_GPG=true
5151

5252
# Prepare environment
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Tags: 2.0-preview1-scala_2.12-java17, 2.0-scala_2.12-java17, scala_2.12-java17, 2.0-preview1-java17, 2.0-java17, java17
1+
Tags: 2.0.0-scala_2.12-java17, 2.0-scala_2.12-java17, scala_2.12-java17, 2.0.0-scala_2.12, 2.0-scala_2.12, scala_2.12, 2.0.0-java17, 2.0-java17, java17, 2.0.0, 2.0, latest
22
Architectures: amd64,arm64v8
+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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:21-jre-jammy
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+
# Grab gosu for easy step-down from root
28+
ENV GOSU_VERSION 1.11
29+
RUN set -ex; \
30+
wget -nv -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)"; \
31+
wget -nv -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc"; \
32+
export GNUPGHOME="$(mktemp -d)"; \
33+
for server in ha.pool.sks-keyservers.net $(shuf -e \
34+
hkp://p80.pool.sks-keyservers.net:80 \
35+
keyserver.ubuntu.com \
36+
hkp://keyserver.ubuntu.com:80 \
37+
pgp.mit.edu) ; do \
38+
gpg --batch --keyserver "$server" --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && break || : ; \
39+
done && \
40+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
41+
gpgconf --kill all; \
42+
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
43+
chmod +x /usr/local/bin/gosu; \
44+
gosu nobody true
45+
46+
# Configure Flink version
47+
ENV FLINK_TGZ_URL=https://dlcdn.apache.org/flink/flink-2.0.0/flink-2.0.0-bin-scala_2.12.tgz \
48+
FLINK_ASC_URL=https://downloads.apache.org/flink/flink-2.0.0/flink-2.0.0-bin-scala_2.12.tgz.asc \
49+
GPG_KEY=F8E419AA0B60C28879E876859DFF40967ABFC5A4 \
50+
CHECK_GPG=true
51+
52+
# Prepare environment
53+
ENV FLINK_HOME=/opt/flink
54+
ENV PATH=$FLINK_HOME/bin:$PATH
55+
RUN groupadd --system --gid=9999 flink && \
56+
useradd --system --home-dir $FLINK_HOME --uid=9999 --gid=flink flink
57+
WORKDIR $FLINK_HOME
58+
59+
# Install Flink
60+
RUN set -ex; \
61+
wget -nv -O flink.tgz "$FLINK_TGZ_URL"; \
62+
\
63+
if [ "$CHECK_GPG" = "true" ]; then \
64+
wget -nv -O flink.tgz.asc "$FLINK_ASC_URL"; \
65+
export GNUPGHOME="$(mktemp -d)"; \
66+
for server in ha.pool.sks-keyservers.net $(shuf -e \
67+
hkp://p80.pool.sks-keyservers.net:80 \
68+
keyserver.ubuntu.com \
69+
hkp://keyserver.ubuntu.com:80 \
70+
pgp.mit.edu) ; do \
71+
gpg --batch --keyserver "$server" --recv-keys "$GPG_KEY" && break || : ; \
72+
done && \
73+
gpg --batch --verify flink.tgz.asc flink.tgz; \
74+
gpgconf --kill all; \
75+
rm -rf "$GNUPGHOME" flink.tgz.asc; \
76+
fi; \
77+
\
78+
tar -xf flink.tgz --strip-components=1; \
79+
rm flink.tgz; \
80+
\
81+
chown -R flink:flink .; \
82+
\
83+
# Replace default REST/RPC endpoint bind address to use the container's network interface \
84+
CONF_FILE="${FLINK_HOME}/conf/config.yaml"; \
85+
/bin/bash "$FLINK_HOME/bin/config-parser-utils.sh" "${FLINK_HOME}/conf" "${FLINK_HOME}/bin" "${FLINK_HOME}/lib" \
86+
"-repKV" "rest.address,localhost,0.0.0.0" \
87+
"-repKV" "rest.bind-address,localhost,0.0.0.0" \
88+
"-repKV" "jobmanager.bind-host,localhost,0.0.0.0" \
89+
"-repKV" "taskmanager.bind-host,localhost,0.0.0.0" \
90+
"-rmKV" "taskmanager.host=localhost";
91+
92+
# Configure container
93+
COPY docker-entrypoint.sh /
94+
ENTRYPOINT ["/docker-entrypoint.sh"]
95+
EXPOSE 6123 8081
96+
CMD ["help"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
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+
drop_privs_cmd() {
29+
if [ $(id -u) != 0 ]; then
30+
# Don't need to drop privs if EUID != 0
31+
return
32+
elif [ -x /sbin/su-exec ]; then
33+
# Alpine
34+
echo su-exec flink
35+
else
36+
# Others
37+
echo gosu flink
38+
fi
39+
}
40+
41+
copy_plugins_if_required() {
42+
if [ -z "$ENABLE_BUILT_IN_PLUGINS" ]; then
43+
return 0
44+
fi
45+
46+
echo "Enabling required built-in plugins"
47+
for target_plugin in $(echo "$ENABLE_BUILT_IN_PLUGINS" | tr ';' ' '); do
48+
echo "Linking ${target_plugin} to plugin directory"
49+
plugin_name=${target_plugin%.jar}
50+
51+
mkdir -p "${FLINK_HOME}/plugins/${plugin_name}"
52+
if [ ! -e "${FLINK_HOME}/opt/${target_plugin}" ]; then
53+
echo "Plugin ${target_plugin} does not exist. Exiting."
54+
exit 1
55+
else
56+
ln -fs "${FLINK_HOME}/opt/${target_plugin}" "${FLINK_HOME}/plugins/${plugin_name}"
57+
echo "Successfully enabled ${target_plugin}"
58+
fi
59+
done
60+
}
61+
62+
set_config_options() {
63+
local config_parser_script="$FLINK_HOME/bin/config-parser-utils.sh"
64+
local config_dir="$FLINK_HOME/conf"
65+
local bin_dir="$FLINK_HOME/bin"
66+
local lib_dir="$FLINK_HOME/lib"
67+
68+
local config_params=()
69+
70+
while [ $# -gt 0 ]; do
71+
local key="$1"
72+
local value="$2"
73+
74+
config_params+=("-D${key}=${value}")
75+
76+
shift 2
77+
done
78+
79+
if [ "${#config_params[@]}" -gt 0 ]; then
80+
"${config_parser_script}" "${config_dir}" "${bin_dir}" "${lib_dir}" "${config_params[@]}"
81+
fi
82+
}
83+
84+
prepare_configuration() {
85+
local config_options=()
86+
87+
config_options+=("jobmanager.rpc.address" "${JOB_MANAGER_RPC_ADDRESS}")
88+
config_options+=("blob.server.port" "6124")
89+
config_options+=("query.server.port" "6125")
90+
91+
if [ -n "${TASK_MANAGER_NUMBER_OF_TASK_SLOTS}" ]; then
92+
config_options+=("taskmanager.numberOfTaskSlots" "${TASK_MANAGER_NUMBER_OF_TASK_SLOTS}")
93+
fi
94+
95+
if [ ${#config_options[@]} -ne 0 ]; then
96+
set_config_options "${config_options[@]}"
97+
fi
98+
99+
if [ -n "${FLINK_PROPERTIES}" ]; then
100+
process_flink_properties "${FLINK_PROPERTIES}"
101+
fi
102+
}
103+
104+
process_flink_properties() {
105+
local flink_properties_content=$1
106+
local config_options=()
107+
108+
local OLD_IFS="$IFS"
109+
IFS=$'\n'
110+
for prop in $flink_properties_content; do
111+
prop=$(echo $prop | tr -d '[:space:]')
112+
113+
if [ -z "$prop" ]; then
114+
continue
115+
fi
116+
117+
IFS=':' read -r key value <<< "$prop"
118+
119+
value=$(echo $value | envsubst)
120+
121+
config_options+=("$key" "$value")
122+
done
123+
IFS="$OLD_IFS"
124+
125+
if [ ${#config_options[@]} -ne 0 ]; then
126+
set_config_options "${config_options[@]}"
127+
fi
128+
}
129+
130+
maybe_enable_jemalloc() {
131+
if [ "${DISABLE_JEMALLOC:-false}" == "false" ]; then
132+
JEMALLOC_PATH="/usr/lib/$(uname -m)-linux-gnu/libjemalloc.so"
133+
JEMALLOC_FALLBACK="/usr/lib/x86_64-linux-gnu/libjemalloc.so"
134+
if [ -f "$JEMALLOC_PATH" ]; then
135+
export LD_PRELOAD=$LD_PRELOAD:$JEMALLOC_PATH
136+
elif [ -f "$JEMALLOC_FALLBACK" ]; then
137+
export LD_PRELOAD=$LD_PRELOAD:$JEMALLOC_FALLBACK
138+
else
139+
if [ "$JEMALLOC_PATH" = "$JEMALLOC_FALLBACK" ]; then
140+
MSG_PATH=$JEMALLOC_PATH
141+
else
142+
MSG_PATH="$JEMALLOC_PATH and $JEMALLOC_FALLBACK"
143+
fi
144+
echo "WARNING: attempted to load jemalloc from $MSG_PATH but the library couldn't be found. glibc will be used instead."
145+
fi
146+
fi
147+
}
148+
149+
maybe_enable_jemalloc
150+
151+
copy_plugins_if_required
152+
153+
prepare_configuration
154+
155+
args=("$@")
156+
if [ "$1" = "help" ]; then
157+
printf "Usage: $(basename "$0") (jobmanager|${COMMAND_STANDALONE}|taskmanager|${COMMAND_HISTORY_SERVER})\n"
158+
printf " Or $(basename "$0") help\n\n"
159+
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"
160+
exit 0
161+
elif [ "$1" = "jobmanager" ]; then
162+
args=("${args[@]:1}")
163+
164+
echo "Starting Job Manager"
165+
166+
exec $(drop_privs_cmd) "$FLINK_HOME/bin/jobmanager.sh" start-foreground "${args[@]}"
167+
elif [ "$1" = ${COMMAND_STANDALONE} ]; then
168+
args=("${args[@]:1}")
169+
170+
echo "Starting Job Manager"
171+
172+
exec $(drop_privs_cmd) "$FLINK_HOME/bin/standalone-job.sh" start-foreground "${args[@]}"
173+
elif [ "$1" = ${COMMAND_HISTORY_SERVER} ]; then
174+
args=("${args[@]:1}")
175+
176+
echo "Starting History Server"
177+
178+
exec $(drop_privs_cmd) "$FLINK_HOME/bin/historyserver.sh" start-foreground "${args[@]}"
179+
elif [ "$1" = "taskmanager" ]; then
180+
args=("${args[@]:1}")
181+
182+
echo "Starting Task Manager"
183+
184+
exec $(drop_privs_cmd) "$FLINK_HOME/bin/taskmanager.sh" start-foreground "${args[@]}"
185+
fi
186+
187+
args=("${args[@]}")
188+
189+
# Running command in pass-through mode
190+
exec $(drop_privs_cmd) "${args[@]}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Tags: 2.0.0-scala_2.12-java21, 2.0-scala_2.12-java21, scala_2.12-java21, 2.0.0-java21, 2.0-java21, java21
2+
Architectures: amd64,arm64v8

0 commit comments

Comments
 (0)