Skip to content

Commit 3154e48

Browse files
committed
[FLINK-32931][docker] Update Dockerfiles for 1.18.0 release
1 parent 45c6d23 commit 3154e48

File tree

11 files changed

+749
-5
lines changed

11 files changed

+749
-5
lines changed

.github/workflows/snapshot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ jobs:
3838
matrix:
3939
java_version: [8, 11]
4040
build:
41-
- flink_version: 1.18-SNAPSHOT
41+
- flink_version: 1.19-SNAPSHOT
4242
branch: dev-master
43+
- flink_version: 1.18-SNAPSHOT
44+
branch: dev-1.18
4345
- flink_version: 1.17-SNAPSHOT
4446
branch: dev-1.17
4547
- flink_version: 1.16-SNAPSHOT
4648
branch: dev-1.16
47-
- flink_version: 1.15-SNAPSHOT
48-
branch: dev-1.15
4949
steps:
5050
- uses: actions/checkout@v3
5151
with:
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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-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://www.apache.org/dyn/closer.cgi?action=download&filename=flink/flink-1.18.0/flink-1.18.0-bin-scala_2.12.tgz \
48+
FLINK_ASC_URL=https://www.apache.org/dist/flink/flink-1.18.0/flink-1.18.0-bin-scala_2.12.tgz.asc \
49+
GPG_KEY=96AE0E32CBE6E0753CE6DF6CB078D1D3253A8D82 \
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+
sed -i 's/rest.address: localhost/rest.address: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
85+
sed -i 's/rest.bind-address: localhost/rest.bind-address: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
86+
sed -i 's/jobmanager.bind-host: localhost/jobmanager.bind-host: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
87+
sed -i 's/taskmanager.bind-host: localhost/taskmanager.bind-host: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
88+
sed -i '/taskmanager.host: localhost/d' $FLINK_HOME/conf/flink-conf.yaml;
89+
90+
# Configure container
91+
COPY docker-entrypoint.sh /
92+
ENTRYPOINT ["/docker-entrypoint.sh"]
93+
EXPOSE 6123 8081
94+
CMD ["help"]
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
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="${FLINK_HOME}/conf/flink-conf.yaml"
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_option() {
63+
local option=$1
64+
local value=$2
65+
66+
# escape periods for usage in regular expressions
67+
local escaped_option=$(echo ${option} | sed -e "s/\./\\\./g")
68+
69+
# either override an existing entry, or append a new one
70+
if grep -E "^${escaped_option}:.*" "${CONF_FILE}" > /dev/null; then
71+
sed -i -e "s/${escaped_option}:.*/$option: $value/g" "${CONF_FILE}"
72+
else
73+
echo "${option}: ${value}" >> "${CONF_FILE}"
74+
fi
75+
}
76+
77+
prepare_configuration() {
78+
set_config_option jobmanager.rpc.address ${JOB_MANAGER_RPC_ADDRESS}
79+
set_config_option blob.server.port 6124
80+
set_config_option query.server.port 6125
81+
82+
if [ -n "${TASK_MANAGER_NUMBER_OF_TASK_SLOTS}" ]; then
83+
set_config_option taskmanager.numberOfTaskSlots ${TASK_MANAGER_NUMBER_OF_TASK_SLOTS}
84+
fi
85+
86+
if [ -n "${FLINK_PROPERTIES}" ]; then
87+
echo "${FLINK_PROPERTIES}" >> "${CONF_FILE}"
88+
fi
89+
envsubst < "${CONF_FILE}" > "${CONF_FILE}.tmp" && mv "${CONF_FILE}.tmp" "${CONF_FILE}"
90+
}
91+
92+
maybe_enable_jemalloc() {
93+
if [ "${DISABLE_JEMALLOC:-false}" == "false" ]; then
94+
JEMALLOC_PATH="/usr/lib/$(uname -m)-linux-gnu/libjemalloc.so"
95+
JEMALLOC_FALLBACK="/usr/lib/x86_64-linux-gnu/libjemalloc.so"
96+
if [ -f "$JEMALLOC_PATH" ]; then
97+
export LD_PRELOAD=$LD_PRELOAD:$JEMALLOC_PATH
98+
elif [ -f "$JEMALLOC_FALLBACK" ]; then
99+
export LD_PRELOAD=$LD_PRELOAD:$JEMALLOC_FALLBACK
100+
else
101+
if [ "$JEMALLOC_PATH" = "$JEMALLOC_FALLBACK" ]; then
102+
MSG_PATH=$JEMALLOC_PATH
103+
else
104+
MSG_PATH="$JEMALLOC_PATH and $JEMALLOC_FALLBACK"
105+
fi
106+
echo "WARNING: attempted to load jemalloc from $MSG_PATH but the library couldn't be found. glibc will be used instead."
107+
fi
108+
fi
109+
}
110+
111+
maybe_enable_jemalloc
112+
113+
copy_plugins_if_required
114+
115+
prepare_configuration
116+
117+
args=("$@")
118+
if [ "$1" = "help" ]; then
119+
printf "Usage: $(basename "$0") (jobmanager|${COMMAND_STANDALONE}|taskmanager|${COMMAND_HISTORY_SERVER})\n"
120+
printf " Or $(basename "$0") help\n\n"
121+
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"
122+
exit 0
123+
elif [ "$1" = "jobmanager" ]; then
124+
args=("${args[@]:1}")
125+
126+
echo "Starting Job Manager"
127+
128+
exec $(drop_privs_cmd) "$FLINK_HOME/bin/jobmanager.sh" start-foreground "${args[@]}"
129+
elif [ "$1" = ${COMMAND_STANDALONE} ]; then
130+
args=("${args[@]:1}")
131+
132+
echo "Starting Job Manager"
133+
134+
exec $(drop_privs_cmd) "$FLINK_HOME/bin/standalone-job.sh" start-foreground "${args[@]}"
135+
elif [ "$1" = ${COMMAND_HISTORY_SERVER} ]; then
136+
args=("${args[@]:1}")
137+
138+
echo "Starting History Server"
139+
140+
exec $(drop_privs_cmd) "$FLINK_HOME/bin/historyserver.sh" start-foreground "${args[@]}"
141+
elif [ "$1" = "taskmanager" ]; then
142+
args=("${args[@]:1}")
143+
144+
echo "Starting Task Manager"
145+
146+
exec $(drop_privs_cmd) "$FLINK_HOME/bin/taskmanager.sh" start-foreground "${args[@]}"
147+
fi
148+
149+
args=("${args[@]}")
150+
151+
# Running command in pass-through mode
152+
exec $(drop_privs_cmd) "${args[@]}"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Tags: 1.18.0-scala_2.12-java11, 1.18-scala_2.12-java11, scala_2.12-java11, 1.18.0-scala_2.12, 1.18-scala_2.12, scala_2.12, 1.18.0-java11, 1.18-java11, java11, 1.18.0, 1.18, latest
2+
Architectures: amd64,arm64v8
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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-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://www.apache.org/dyn/closer.cgi?action=download&filename=flink/flink-1.18.0/flink-1.18.0-bin-scala_2.12.tgz \
48+
FLINK_ASC_URL=https://www.apache.org/dist/flink/flink-1.18.0/flink-1.18.0-bin-scala_2.12.tgz.asc \
49+
GPG_KEY=96AE0E32CBE6E0753CE6DF6CB078D1D3253A8D82 \
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+
sed -i 's/rest.address: localhost/rest.address: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
85+
sed -i 's/rest.bind-address: localhost/rest.bind-address: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
86+
sed -i 's/jobmanager.bind-host: localhost/jobmanager.bind-host: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
87+
sed -i 's/taskmanager.bind-host: localhost/taskmanager.bind-host: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
88+
sed -i '/taskmanager.host: localhost/d' $FLINK_HOME/conf/flink-conf.yaml;
89+
90+
# Configure container
91+
COPY docker-entrypoint.sh /
92+
ENTRYPOINT ["/docker-entrypoint.sh"]
93+
EXPOSE 6123 8081
94+
CMD ["help"]

0 commit comments

Comments
 (0)