Skip to content

Commit

Permalink
[Improve] Update docker doc and build tag (apache#7486)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hisoka-X authored Aug 27, 2024
1 parent a4ba6a1 commit 647d2d9
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 39 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ on:
push:
tags:
- '*'
branches:
- dev
paths-ignore:
- 'docs/**'
- '**/*.md'
Expand Down Expand Up @@ -72,8 +70,8 @@ jobs:
MAVEN_OPTS: -Xmx4096m
run: |
./mvnw -B clean install \
-Dmaven.test.skip \
-Dmaven.javadoc.skip \
-Dmaven.test.skip=true \
-Dmaven.javadoc.skip=true \
-Dlicense.skipAddThirdParty=true \
-D"docker.build.skip"=false \
-D"docker.verify.skip"=false \
Expand Down
48 changes: 42 additions & 6 deletions docs/en/start-v2/docker/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_position: 3
---

# Set Up with Docker in local mode
# Set Up With Docker In Local Mode

## Zeta Engine

Expand All @@ -15,17 +15,53 @@ docker pull apache/seatunnel:<version_tag>
How to submit job in local mode

```shell
docker run --rm -it apache/seatunnel bash ./bin/seatunnel.sh -e local -c <CONFIG_FILE>
# Run fake source to console sink
docker run --rm -it apache/seatunnel:<version_tag> ./bin/seatunnel.sh -m local -c config/v2.batch.config.template

# Run job with custom config file
docker run --rm -it -v /<The-Config-Directory-To-Mount>/:/config apache/seatunnel:<version_tag> ./bin/seatunnel.sh -m local -c /config/fake_to_console.conf

# eg: a fake source to console sink
docker run --rm -it apache/seatunnel bash ./bin/seatunnel.sh -e local -c config/v2.batch.config.template
# Example
# If you config file is in /tmp/job/fake_to_console.conf
docker run --rm -it -v /tmp/job/:/config apache/seatunnel:<version_tag> ./bin/seatunnel.sh -m local -c /config/fake_to_console.conf

# Set JVM options when running
docker run --rm -it -v /tmp/job/:/config apache/seatunnel:<version_tag> ./bin/seatunnel.sh -DJvmOption="-Xms4G -Xmx4G" -m local -c /config/fake_to_console.conf
```

### Build Image By Yourself

```Dockerfile
Build from source code. The way of downloading the source code is the same as the way of downloading the binary package.
You can download the source code from the [download page](https://seatunnel.apache.org/download/) or clone the source code from the [GitHub repository](https://github.com/apache/seatunnel/releases)

#### Build With One Command
```shell
cd seatunnel
# Use already sett maven profile
mvn -B clean install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Dlicense.skipAddThirdParty=true -D"docker.build.skip"=false -D"docker.verify.skip"=false -D"docker.push.skip"=true -D"docker.tag"=2.3.8 -Dmaven.deploy.skip --no-snapshot-updates -Pdocker,seatunnel

# Check the docker image
docker images | grep apache/seatunnel
```

#### Build Step By Step
```shell
# Build binary package from source code
mvn clean package -DskipTests -Dskip.spotless=true

# Build docker image
cd seatunnel-dist
docker build -f src/main/docker/Dockerfile --build-arg VERSION=2.3.8 -t apache/seatunnel:2.3.8 .

# If you build from dev branch, you should add SNAPSHOT suffix to the version
docker build -f src/main/docker/Dockerfile --build-arg VERSION=2.3.8-SNAPSHOT -t apache/seatunnel:2.3.8-SNAPSHOT .

# Check the docker image
docker images | grep apache/seatunnel
```

The Dockerfile is like this:
```dockerfile
FROM openjdk:8

ARG VERSION
Expand Down Expand Up @@ -64,7 +100,7 @@ docker run \

Or you can change the `SPARK_HOME`, `FLINK_HOME` environment variable in Dockerfile and re-build your and mount the spark/flink to related path.

```Dockerfile
```dockerfile
FROM apache/seatunnel

ENV SPARK_HOME=<YOUR_CUSTOMIZATION_PATH>
Expand Down
6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,8 @@
<argument>--no-cache</argument>
<argument>-t</argument>
<argument>${docker.hub}/${docker.repo}:${docker.tag}</argument>
<argument>-t</argument>
<argument>${docker.hub}/${docker.repo}:latest</argument>
<argument>${project.basedir}</argument>
<argument>--build-arg</argument>
<argument>VERSION=${project.version}</argument>
Expand Down Expand Up @@ -842,8 +844,8 @@
<argument>linux/amd64,linux/arm64</argument>
<argument>--no-cache</argument>
<argument>--push</argument>
<argument>-t</argument>
<argument>${docker.hub}/${docker.repo}:${docker.tag}</argument>
<argument>--all-tags</argument>
<argument>${docker.hub}/${docker.repo}</argument>
<argument>${project.basedir}</argument>
<argument>--build-arg</argument>
<argument>VERSION=${revision}</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ for %%I in (%*) do (

set "JAVA_OPTS=%JvmOption%"
set "SEATUNNEL_CONFIG=%CONF_DIR%\seatunnel.yaml"
for %%I in (%*) do (
set "arg=%%I"
if "!arg:~0,10!"=="JvmOption=" (
set "JAVA_OPTS=%JAVA_OPTS% !arg:~10!"
)
)

set "JAVA_OPTS=%JAVA_OPTS% -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"

Expand Down Expand Up @@ -104,6 +98,14 @@ if "%NODE_ROLE%" == "master" (
exit 1
)

REM Parse JvmOption from command line, it should be parsed after jvm_options
for %%I in (%*) do (
set "arg=%%I"
if "!arg:~0,10!"=="JvmOption=" (
set "JAVA_OPTS=%JAVA_OPTS% !arg:~10!"
)
)

IF NOT EXIST "%HAZELCAST_CONFIG%" (
echo Error: File %HAZELCAST_CONFIG% does not exist.
exit /b 1
Expand Down
12 changes: 10 additions & 2 deletions seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ fi
for i in "$@"
do
if [[ "${i}" == *"JvmOption"* ]]; then
JVM_OPTION="${i}"
JAVA_OPTS="${JAVA_OPTS} ${JVM_OPTION#*=}"
:
elif [[ "${i}" == "-d" || "${i}" == "--daemon" ]]; then
DAEMON=true
elif [[ "${i}" == "-r" || "${i}" == "--role" ]]; then
Expand Down Expand Up @@ -139,6 +138,15 @@ JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.config=${HAZELCAST_CONFIG}"
# port in your IDE. After that, you can happily debug your code.
# JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5001,suspend=n"

# Parse JvmOption from command line, it should be parsed after jvm_options
for i in "$@"
do
if [[ "${i}" == *"JvmOption"* ]]; then
JVM_OPTION="${i}"
JAVA_OPTS="${JAVA_OPTS} ${JVM_OPTION#*=}"
fi
done

CLASS_PATH=${APP_DIR}/lib/*:${APP_JAR}

echo "start ${NODE_ROLE} node"
Expand Down
21 changes: 11 additions & 10 deletions seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ if defined JvmOption (
set "JAVA_OPTS=%JAVA_OPTS% %JvmOption%"
)

for %%i in (%*) do (
set "arg=%%i"
if "!arg:~0,9!"=="JvmOption" (
set "JVM_OPTION=!arg:~9!"
set "JAVA_OPTS=!JAVA_OPTS! !JVM_OPTION!"
goto :break_loop
)
)
:break_loop

set "JAVA_OPTS=%JAVA_OPTS% -Dhazelcast.client.config=%HAZELCAST_CLIENT_CONFIG%"
set "JAVA_OPTS=%JAVA_OPTS% -Dseatunnel.config=%SEATUNNEL_CONFIG%"
set "JAVA_OPTS=%JAVA_OPTS% -Dhazelcast.config=%HAZELCAST_CONFIG%"
Expand Down Expand Up @@ -105,4 +95,15 @@ for /f "usebackq delims=" %%a in ("%APP_DIR%\config\jvm_client_options") do (
)
)

REM Parse JvmOption from command line, it should be parsed after jvm_client_options
for %%i in (%*) do (
set "arg=%%i"
if "!arg:~0,9!"=="JvmOption" (
set "JVM_OPTION=!arg:~9!"
set "JAVA_OPTS=!JAVA_OPTS! !JVM_OPTION!"
goto :break_loop
)
)
:break_loop

java %JAVA_OPTS% -cp %CLASS_PATH% %APP_MAIN% %args%
19 changes: 10 additions & 9 deletions seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ if test ${JvmOption} ;then
JAVA_OPTS="${JAVA_OPTS} ${JvmOption}"
fi

for i in "$@"
do
if [[ "${i}" == *"JvmOption"* ]]; then
JVM_OPTION="${i}"
JAVA_OPTS="${JAVA_OPTS} ${JVM_OPTION#*=}"
break
fi
done

JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.client.config=${HAZELCAST_CLIENT_CONFIG}"
JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.config=${SEATUNNEL_CONFIG}"
JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.config=${HAZELCAST_CONFIG}"
Expand Down Expand Up @@ -108,4 +99,14 @@ while IFS= read -r line || [[ -n "$line" ]]; do
fi
done < ${APP_DIR}/config/jvm_client_options

# Parse JvmOption from command line, it should be parsed after jvm_client_options
for i in "$@"
do
if [[ "${i}" == *"JvmOption"* ]]; then
JVM_OPTION="${i}"
JAVA_OPTS="${JAVA_OPTS} ${JVM_OPTION#*=}"
break
fi
done

java ${JAVA_OPTS} -cp ${CLASS_PATH} ${APP_MAIN} ${args}

0 comments on commit 647d2d9

Please sign in to comment.