This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new 8b5b200da [Improvement-3802] docker image related optimization (#3804)
8b5b200da is described below
commit 8b5b200daa0810b2c32dbfb6ce7fae170dfd6a9c
Author: xiangzihao <[email protected]>
AuthorDate: Wed Jun 26 11:41:43 2024 +0800
[Improvement-3802] docker image related optimization (#3804)
* docker improvement
* fix datasource env
---
docker/.env | 33 ----------------
docker/Dockerfile | 98 +++++++++++++++++++++++++++++-----------------
docker/docker-compose.yaml | 54 +++++++++----------------
3 files changed, 80 insertions(+), 105 deletions(-)
diff --git a/docker/.env b/docker/.env
deleted file mode 100644
index 800c55d9c..000000000
--- a/docker/.env
+++ /dev/null
@@ -1,33 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-TZ=Asia/Shanghai
-
-SPRING_PROFILES_ACTIVE=h2 #mysql, pgsql
-# If use mysql or pgsql, please set the following parameters
-#SPRING_DATASOURCE_URL=jdbc:mysql://localhost:3306/streampark?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
-#SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/streampark?stringtype=unspecified
-#SPRING_DATASOURCE_USERNAME=root
-#SPRING_DATASOURCE_PASSWORD=streampark
-
-FLINK=flink1.14.5
-FLINK_IMAGE=flink:1.14.5-scala_2.12
-
-RUN_COMMAND='/bin/sh -c "wget -P lib
https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/8.0.31/mysql-connector-j-8.0.31.jar
&& bash bin/streampark.sh start_docker "'
-
-JOB_MANAGER_RPC_ADDRESS=flink-jobmanager
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 87bc45a0b..7451712e4 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -14,40 +14,66 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+FROM ubuntu:22.04
-FROM alpine:3.16 as deps-stage
-COPY . /
-WORKDIR /
-RUN tar zxvf dist/apache-streampark*-*-bin.tar.gz \
-&& mv apache-streampark*-*-bin streampark
-
-FROM docker:dind
-WORKDIR /streampark
-COPY --from=deps-stage /streampark /streampark
-
-ENV NODE_VERSION=16.1.0
-ENV NPM_VERSION=7.11.2
-
-RUN apk add openjdk8 \
- && apk add maven \
- && apk add wget \
- && apk add vim \
- && apk add bash \
- && apk add curl
-
-ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
-ENV MAVEN_HOME=/usr/share/java/maven-3
-ENV PATH $JAVA_HOME/bin:$PATH
-ENV PATH $MAVEN_HOME/bin:$PATH
-
-RUN wget
"https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" \
- && tar zxvf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local
--strip-components=1 \
- && rm "node-v$NODE_VERSION-linux-x64.tar.gz" \
- && ln -s /usr/local/bin/node /usr/local/bin/nodejs \
- && curl -LO https://dl.k8s.io/release/v1.23.0/bin/linux/amd64/kubectl \
- && install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
-
-RUN mkdir -p ~/.kube
-
-EXPOSE 10000
-EXPOSE 10030
+USER root
+
+# Install basic tools
+RUN apt update && apt install -y wget curl vim net-tools iputils-ping \
+ && apt install software-properties-common -y \
+ && add-apt-repository ppa:openjdk-r/ppa -y
+RUN apt update && apt install -y openjdk-8-jdk
+RUN JAVA_PATH=$(ls -l /usr/lib/jvm | grep java-8-openjdk | grep ^d | awk -F '
' '{print $9}'); \
+ if [ -z "${JAVA_PATH}" ];then \
+ echo "JAVA_PATH not found: $JAVA_PATH"; \
+ exit 2; \
+ else \
+ ln -s /usr/lib/jvm/$JAVA_PATH/ /usr/lib/jvm/jdk8; \
+ fi
+ENV JAVA_HOME=/usr/lib/jvm/jdk8
+
+
+# Install docker
+RUN \
+ # Add Docker's official GPG key:
+ apt update && \
+ apt install -y ca-certificates curl gnupg && \
+ install -m 0755 -d /etc/apt/keyrings && \
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o
/etc/apt/keyrings/docker.gpg && \
+ chmod a+r /etc/apt/keyrings/docker.gpg && \
+ # Add the repository to Apt sources:
+ echo \
+ "deb [arch="$(dpkg --print-architecture)"
signed-by=/etc/apt/keyrings/docker.gpg]
https://download.docker.com/linux/ubuntu \
+ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
+ tee /etc/apt/sources.list.d/docker.list > /dev/null && \
+ apt update && \
+ # Install the Docker packages.
+ apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin
docker-compose-plugin
+
+
+# Install Tini
+ARG TARGETPLATFORM
+ENV TINI_VERSION v0.19.0
+RUN echo "TARGETPLATFORM: $TARGETPLATFORM"
+RUN \
+ if [ "$TARGETPLATFORM" = "linux/amd64" ];then \
+ TINI_PLATFORM=amd64; \
+ wget --no-check-certificate -O /usr/sbin/tini
https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-$TINI_PLATFORM;
\
+ elif [ "$TARGETPLATFORM" = "linux/arm64" ];then \
+ TINI_PLATFORM=arm64; \
+ wget --no-check-certificate -O /usr/sbin/tini
https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-$TINI_PLATFORM;
\
+ else \
+ echo "unknown TARGETPLATFORM: $TARGETPLATFORM"; \
+ exit 2; \
+ fi
+RUN chmod +x /usr/sbin/tini
+
+
+# Install StreamPark
+COPY dist/apache-streampark*-*-bin.tar.gz /
+RUN tar -zxvf apache-streampark*-*-bin.tar.gz \
+ && mv apache-streampark*-*-bin streampark \
+ && rm -f apache-streampark*-*-bin.tar.gz
+
+
+ENTRYPOINT ["/usr/sbin/tini", "--", "/streampark/bin/streampark.sh",
"start_docker"]
diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml
index 78817deb2..d4ab8b156 100644
--- a/docker/docker-compose.yaml
+++ b/docker/docker-compose.yaml
@@ -15,53 +15,35 @@
# limitations under the License.
version: '3.8'
+
services:
- streampark-console:
+ streampark:
image: apache/streampark:2.2.0
- command: ${RUN_COMMAND}
ports:
- - 10000:10000
- - 10030:10030
- env_file: .env
+ - "10000:10000"
+ - "10030:10030"
+ environment:
+ - TZ=Asia/Shanghai
+ - DATASOURCE_DIALECT=h2 # h2, mysql, pgsql
+# If use mysql or pgsql, please set the following parameters
+# -
DATASOURCE_URL=jdbc:mysql://localhost:3306/streampark?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
+# -
DATASOURCE_URL=jdbc:postgresql://localhost:5432/streampark?stringtype=unspecified
+# - DATASOURCE_USERNAME=root
+# - DATASOURCE_PASSWORD=streampark
volumes:
- - flink:/streampark/flink/${FLINK}
- /var/run/docker.sock:/var/run/docker.sock
- /etc/hosts:/etc/hosts:ro
- ~/.kube:/root/.kube:ro
privileged: true
- restart: unless-stopped
- networks:
- - streampark
-
- flink-jobmanager:
- image: ${FLINK_IMAGE}
- ports:
- - "8081:8081"
- command: jobmanager
- volumes:
- - flink:/opt/flink
- env_file: .env
- restart: unless-stopped
- privileged: true
- networks:
- - streampark
-
- flink-taskmanager:
- image: ${FLINK_IMAGE}
- depends_on:
- - flink-jobmanager
- command: taskmanager
- deploy:
- replicas: 1
- env_file: .env
- restart: unless-stopped
- privileged: true
+ restart: always
networks:
- streampark
+ healthcheck:
+ test: [ "CMD", "curl", "http://streampark:10000" ]
+ interval: 5s
+ timeout: 5s
+ retries: 120
networks:
streampark:
driver: bridge
-
-volumes:
- flink: