You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sd...@apache.org on 2022/12/13 13:49:35 UTC
[ignite-3] branch main updated: IGNITE-17920 Develop docker-compose file for Ignite cluster (#1228)
This is an automated email from the ASF dual-hosted git repository.
sdanilov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new cbb177189b IGNITE-17920 Develop docker-compose file for Ignite cluster (#1228)
cbb177189b is described below
commit cbb177189ba3bf24ca9ff0a04dda132bc674d3c0
Author: Vadim Pakhnushev <86...@users.noreply.github.com>
AuthorDate: Tue Dec 13 16:49:30 2022 +0300
IGNITE-17920 Develop docker-compose file for Ignite cluster (#1228)
---
DEVNOTES.md | 8 +++++
packaging/build.gradle | 67 +++++++++++++++++++++++++----------
packaging/docker/Dockerfile | 33 ++++++++++++++---
packaging/docker/docker-compose.yml | 42 ++++++++++++++++++++++
packaging/docker/docker-entrypoint.sh | 5 +++
5 files changed, 132 insertions(+), 23 deletions(-)
diff --git a/DEVNOTES.md b/DEVNOTES.md
index e03a625c7a..f8ac0d69ba 100644
--- a/DEVNOTES.md
+++ b/DEVNOTES.md
@@ -437,6 +437,14 @@ Run docker container with ignite node:
docker run -it --rm -p 10300:10300 apacheignite/ignite3
```
+There's a sample docker compose file which allows to run 3 nodes in a cluster in the `packaging/docker` directory. You can also use CLI from
+the docker image using `cli` parameter and connect to nodes using their names from the docker network.
+```shell
+docker compose -f packaging/docker/docker-compose.yml up -d
+docker run -it --rm --net ignite3_default apacheignite/ignite3 cli
+> connect http://node1:10300
+> cluster init --cluster-name cluster --meta-storage-node node1 --meta-storage-node node2 --meta-storage-node node3
+```
## Release candidate verification
1. Build all packages (this will also run unit tests and all checks)
diff --git a/packaging/build.gradle b/packaging/build.gradle
index 5423b4fa9b..b04c64e175 100644
--- a/packaging/build.gradle
+++ b/packaging/build.gradle
@@ -28,6 +28,7 @@ import org.gradle.crypto.checksum.Checksum
configurations {
dbArtifacts
+ cliArtifacts
cliZip
dbZip
cliRelease
@@ -37,6 +38,7 @@ configurations {
dependencies {
dbArtifacts(project(':ignite-runner'))
+ cliArtifacts(project(':ignite-cli'))
cliZip(project(path: ':packaging-cli', configuration: 'cliZip'))
dbZip(project(path: ':packaging-db', configuration: 'dbZip'))
cliRelease(project(path: ':packaging-cli', configuration: 'cliRelease'))
@@ -44,6 +46,17 @@ dependencies {
platformsRelease(project(path: ':platforms', configuration: 'platformsRelease'))
}
+// Task that generates start script for cli
+task cliStartScript(type: CreateStartScripts) {
+ // Will be passed to exec "java ... <mainClassName>"
+ mainClass = "org.apache.ignite.internal.cli.Main"
+ // Forms a classpath string that will be passed to exec "java -cp <classpath> .."
+ // it is expected to locate the "lib" dir together with "bin"
+ classpath = files 'lib/*'
+ outputDir = file "$buildDir/scripts"
+ applicationName = 'ignite3'
+}
+
def tokens = [
INSTALL_DIR : '${IGNITE_HOME}',
CONF_DIR : '${IGNITE_HOME}/etc',
@@ -67,28 +80,44 @@ docker {
copySpec.into 'dist', {
into('') {
- File.createTempDir().with {
- ['etc', 'work'].each { new File(absolutePath, it).mkdirs() }
- from(absolutePath) {
- includeEmptyDirs = true
- }
- }
- from("$rootDir/LICENSE")
- from("$rootDir/NOTICE")
- from("$rootDir/assembly/README.md")
- }
- into('etc') {
- from('config/ignite-config.conf')
- from('docker/ignite.java.util.logging.properties')
- }
- into('bin') {
fileMode 0755
from("$buildDir/docker/docker-entrypoint.sh")
}
- into('lib') {
- from(configurations.dbArtifacts)
- from("$buildDir/docker/$tokens.BOOTSTRAP_FILE_NAME")
- from("$buildDir/docker/$tokens.SETUP_JAVA_FILE_NAME")
+ into('db') {
+ into('') {
+ File.createTempDir().with {
+ ['etc', 'work'].each { new File(absolutePath, it).mkdirs() }
+ from(absolutePath) {
+ includeEmptyDirs = true
+ }
+ }
+ from("$rootDir/LICENSE")
+ from("$rootDir/NOTICE")
+ from("$rootDir/assembly/README.md")
+ }
+ into('etc') {
+ from('config/ignite-config.conf')
+ from('docker/ignite.java.util.logging.properties')
+ }
+ into('lib') {
+ from(configurations.dbArtifacts)
+ from("$buildDir/docker/$tokens.BOOTSTRAP_FILE_NAME")
+ from("$buildDir/docker/$tokens.SETUP_JAVA_FILE_NAME")
+ }
+ }
+ into('cli') {
+ into('') {
+ from("$rootDir/LICENSE")
+ from("$rootDir/NOTICE")
+ from("$rootDir/assembly/README.md")
+ }
+ into('bin') {
+ fileMode 0755
+ from(cliStartScript)
+ }
+ into('lib') {
+ from(configurations.cliArtifacts)
+ }
}
}
}
diff --git a/packaging/docker/Dockerfile b/packaging/docker/Dockerfile
index 560aea914d..deba47c854 100644
--- a/packaging/docker/Dockerfile
+++ b/packaging/docker/Dockerfile
@@ -1,5 +1,21 @@
-FROM eclipse-temurin:11-jre
+FROM eclipse-temurin:11 as jre-build
+RUN $JAVA_HOME/bin/jlink \
+ --add-modules ALL-MODULE-PATH \
+ --strip-debug \
+ --no-man-pages \
+ --no-header-files \
+ --compress=2 \
+ --output /javaruntime
+
+# Same base image as eclipse-temurin
+FROM ubuntu:22.04
+
+ENV JAVA_HOME=/opt/java/openjdk
+ENV PATH "${JAVA_HOME}/bin:${PATH}"
+COPY --from=jre-build /javaruntime $JAVA_HOME
+
+# Copy and setup DB app
ENV IGNITE_HOME /opt/ignite
ENV LIBS_DIR $IGNITE_HOME/lib
@@ -8,7 +24,16 @@ ENV IGNITE_NODE_NAME defaultNode
ENV IGNITE_WORK_DIR $IGNITE_HOME/work
ENV IGNITE_CONFIG_PATH $IGNITE_HOME/etc/ignite-config.conf
-WORKDIR $IGNITE_HOME
-COPY dist .
+COPY dist/db $IGNITE_HOME
+
EXPOSE 3344 10300 10800
-ENTRYPOINT ["bin/docker-entrypoint.sh"]
+
+# Copy CLI app
+ENV IGNITE_CLI_HOME /opt/ignite3cli
+
+COPY dist/cli $IGNITE_CLI_HOME
+
+# Copy entrypoint script
+COPY dist/docker-entrypoint.sh /usr/local/bin/
+
+ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/packaging/docker/docker-compose.yml b/packaging/docker/docker-compose.yml
new file mode 100644
index 0000000000..65c335120d
--- /dev/null
+++ b/packaging/docker/docker-compose.yml
@@ -0,0 +1,42 @@
+# 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.
+
+version: "3.9"
+
+name: ignite3
+
+x-ignite-def:
+ &ignite-def
+ image: apacheignite/ignite3:${IGNITE3_VERSION:-latest}
+
+services:
+ node1:
+ << : *ignite-def
+ command: --join node1:3344,node2:3344,node3:3344 --node-name node1
+ ports:
+ - 10300:10300
+ - 3344:3344
+ node2:
+ << : *ignite-def
+ command: --join node1:3344,node2:3344,node3:3344 --node-name node2
+ ports:
+ - 10301:10300
+ - 3345:3344
+ node3:
+ << : *ignite-def
+ command: --join node1:3344,node2:3344,node3:3344 --node-name node3
+ ports:
+ - 10302:10300
+ - 3346:3344
diff --git a/packaging/docker/docker-entrypoint.sh b/packaging/docker/docker-entrypoint.sh
index 96e71b77b9..af5dd00474 100644
--- a/packaging/docker/docker-entrypoint.sh
+++ b/packaging/docker/docker-entrypoint.sh
@@ -17,6 +17,11 @@
# limitations under the License.
#
+if [ "$1" = 'cli' ]; then
+ shift
+ exec sh "$IGNITE_CLI_HOME"/bin/ignite3 "$@"
+fi
+
. @LIB_DIR@/@BOOTSTRAP_FILE_NAME@
LOGGING_JAVA_OPTS="-Djava.util.logging.config.file=@CONF_DIR@/ignite.java.util.logging.properties"