-
Notifications
You must be signed in to change notification settings - Fork 304
/
build-docker.sh
72 lines (64 loc) · 2.45 KB
/
build-docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# create addax docker image
# the image including two type default and basic
# default: addax with all modules
# basic: addax with basic modules
function get_version() {
version=$(grep -o -E '<version>.*</version>' pom.xml | head -n 1 | sed -e 's/<version>\(.*\)<\/version>/\1/')
echo $version
}
function compress_plugins() {
version=$(get_version)
TMPDIR=$(ls -d -w1 target/addax/addax-${version})
[ -n "$TMPDIR" ] || exit 2
(
cd ${TMPDIR} || exit 3
# should be in target/addax/addax-<version>
[ -d shared ] || mkdir shared
for jar in $(find plugin/*/*/libs -type f -name *.jar)
do
plugin_dir=$(dirname $jar)
file_name=$(basename $jar)
# 1. move it to shared folder
/bin/mv -f ${jar} shared/
# 2. create symbol link
( cd ${plugin_dir} && ln -sf ../../../../shared/${file_name} $file_name )
done
)
echo "The addax-${version} is ready to be compressed"
}
version=$(get_version)
# first compile basic images
mvn clean package -Dmaven.test.skip=true -Pbasic
mvn package assembly:single -Pbasic
compress_plugins
# write a simple Dockerfile for build
cat > /tmp/Dockerfile <<EOF
FROM openjdk:8-jre-alpine
LABEL maintainer="wgzhao <[email protected]>"
LABEL version="$version"
LABEL description="Addax is a versatile open-source ETL tool that can seamlessly transfer data between various RDBMS and NoSQL databases, making it an ideal solution for data migration."
COPY addax-${version} /opt/addax
WORKDIR /opt/addax
RUN chmod +x bin/*.sh
EOF
# build it
docker build -t quay.io/wgzhao/addax:${version}-lite -f /tmp/Dockerfile target/addax
docker tag quay.io/wgzhao/addax:${version}-lite quay.io/wgzhao/addax:latest-lite
# then compile default images
mvn clean package -Dmaven.test.skip=true -Pdefault
mvn package assembly:single -Pdefault
compress_plugins
# write a simple Dockerfile for build
cat > /tmp/Dockerfile <<EOF
FROM openjdk:8-jre-alpine
LABEL maintainer="wgzhao <[email protected]>"
LABEL version="${version}"
LABEL description="Addax is a versatile open-source ETL tool that can seamlessly transfer data between various RDBMS and NoSQL databases, making it an ideal solution for data migration."
COPY addax-${version} /opt/addax
WORKDIR /opt/addax
RUN chmod +x bin/*.sh
EOF
# build it
docker build -t quay.io/wgzhao/addax:${version} -f /tmp/Dockerfile target/addax
docker tag quay.io/wgzhao/addax:${version} quay.io/wgzhao/addax:latest