|
a/scripts/bundle-functions.sh |
|
b/scripts/bundle-functions.sh |
|
... |
|
... |
30 |
|
30 |
|
31 |
function checkProjectDir() {
|
31 |
function checkProjectDir() {
|
32 |
ls ${C2NET_DIR}
|
32 |
ls ${C2NET_DIR}
|
33 |
}
|
33 |
}
|
34 |
|
34 |
|
35 |
function bundleComponent() {
|
35 |
function buildComponent() {
|
36 |
INITIAL_DIR="${PWD}"
|
36 |
INITIAL_DIR="${PWD}"
|
37 |
COMPONENT_NAME=$1
|
37 |
COMPONENT_NAME=$1
|
38 |
RUNTIME=${2:-node}
|
38 |
RUNTIME=${2:-node}
|
39 |
|
39 |
|
40 |
COMP_DIR="${C2NET_DIR}/${COMPONENT_NAME}"
|
40 |
COMP_DIR="${C2NET_DIR}/${COMPONENT_NAME}"
|
|
... |
|
... |
51 |
|
51 |
|
52 |
if [ "$RUNTIME" == "node" ]; then
|
52 |
if [ "$RUNTIME" == "node" ]; then
|
53 |
|
53 |
|
54 |
echo " - Compiling using NodeJS runtime - c2netproject.eu/runtime/nodejs:1_0_0"
|
54 |
echo " - Compiling using NodeJS runtime - c2netproject.eu/runtime/nodejs:1_0_0"
|
55 |
# Launch npm install in a Docker container compatible with the Runtime
|
55 |
# Launch npm install in a Docker container compatible with the Runtime
|
56 |
$DOCKER run --dns=192.168.0.11 --rm -v $PWD:/tmp/component --entrypoint=bash c2netproject.eu/runtime/nodejs:1_0_0 -c "$NPMINSTALL"
|
56 |
$DOCKER run --rm "$DNS" -v $PWD:/tmp/component --entrypoint=bash c2netproject.eu/runtime/nodejs:1_0_0 -c "$NPMINSTALL"
|
|
|
57 |
|
|
|
58 |
|
57 |
echo " - Completed npm install"
|
59 |
echo " - Completed npm install"
|
58 |
|
60 |
|
59 |
# Create code zip (src + package.json)
|
61 |
# Copy src + package.json to bundles
|
60 |
zip -q -r ${COMP_BUNDLES_DIR}/${CODE_ZIP_FILENAME} .
|
62 |
cp -fr ${COMP_DIR} ${COMP_BUNDLES_DIR}
|
61 |
echo " - Created code zip: ${CODE_ZIP_FILENAME}"
|
63 |
echo " - Component copied: ${COMPONENT_NAME}"
|
62 |
|
64 |
|
63 |
# Remove node_modules (requires root)
|
65 |
# Remove node_modules (requires root)
|
64 |
$DOCKER run --rm -v $PWD:/tmp/component --entrypoint=bash c2netproject.eu/runtime/nodejs:1_0_0 -c "rm -rf node_modules"
|
66 |
$DOCKER run --rm -v $PWD:/tmp/component --entrypoint=bash c2netproject.eu/runtime/nodejs:1_0_0 -c "rm -rf node_modules"
|
65 |
echo " - Deleted node_modules"
|
67 |
echo " - Deleted node_modules"
|
66 |
|
|
|
67 |
|
68 |
|
68 |
elif [ "$RUNTIME" == "java" ]; then
|
69 |
elif [ "$RUNTIME" == "java" ]; then
|
69 |
echo " - Compiling using JAVA runtime: $DEV_DOCKER_IMAGE"
|
70 |
echo " - Compiling using JAVA runtime: $DEV_DOCKER_IMAGE"
|
70 |
rm -rf build
|
71 |
rm -rf build
|
71 |
javaCompile $PWD
|
72 |
javaCompile $PWD
|
72 |
cd build
|
73 |
cd build
|
73 |
zip -r ${COMP_BUNDLES_DIR}/${CODE_ZIP_FILENAME} .
|
74 |
zip -r ${COMP_BUNDLES_DIR}/${CODE_ZIP_FILENAME} .
|
74 |
echo " - Created code zip: ${CODE_ZIP_FILENAME}"
|
75 |
echo " - Created code zip: ${CODE_ZIP_FILENAME}"
|
75 |
cd ..
|
76 |
cd ..
|
76 |
|
77 |
|
77 |
$DOCKER run --dns=192.168.0.11 --rm -v $PWD:/tmp/component --entrypoint=bash $DEV_DOCKER_IMAGE -c 'rm -rf build'
|
78 |
$DOCKER run "$DNS" --rm -v $PWD:/tmp/component --entrypoint=bash $DEV_DOCKER_IMAGE -c 'rm -rf build'
|
78 |
echo " - Deleted build dir"
|
79 |
echo " - Deleted build dir"
|
79 |
|
80 |
|
80 |
elif [ "$RUNTIME" == "mariadb" ]; then
|
81 |
elif [ "$RUNTIME" == "mariadb" ]; then
|
81 |
echo " - Compiling using MariaDB runtime - eslap.cloud/runtime/mariadb:1_0_0"
|
82 |
echo " - Compiling using MariaDB runtime - eslap.cloud/runtime/mariadb:1_0_0"
|
82 |
# Launch npm install in a Docker container compatible with the Runtime
|
83 |
# Launch npm install in a Docker container compatible with the Runtime
|
83 |
$DOCKER run --dns=192.168.0.11 --rm -v $PWD:/tmp/component --entrypoint=bash eslap.cloud/runtime/mariadb:1_0_0 -c "$NPMINSTALL"
|
84 |
$DOCKER run "$DNS" --rm -v $PWD:/tmp/component --entrypoint=bash eslap.cloud/runtime/mariadb:1_0_0 -c "$NPMINSTALL"
|
84 |
echo " - Completed npm install"
|
85 |
echo " - Completed npm install"
|
85 |
|
86 |
|
86 |
# Create code zip (src + package.json)
|
87 |
# Create code zip (src + package.json)
|
87 |
zip -q -r ${COMP_BUNDLES_DIR}/${CODE_ZIP_FILENAME} .
|
88 |
zip -q -r ${COMP_BUNDLES_DIR}/${CODE_ZIP_FILENAME} .
|
88 |
echo " - Created code zip: ${CODE_ZIP_FILENAME}"
|
89 |
echo " - Created code zip: ${CODE_ZIP_FILENAME}"
|
|
... |
|
... |
90 |
# Remove node_modules (requires root)
|
91 |
# Remove node_modules (requires root)
|
91 |
$DOCKER run --rm -v $PWD:/tmp/component --entrypoint=bash eslap.cloud/runtime/mariadb:1_0_0 -c "rm -rf node_modules"
|
92 |
$DOCKER run --rm -v $PWD:/tmp/component --entrypoint=bash eslap.cloud/runtime/mariadb:1_0_0 -c "rm -rf node_modules"
|
92 |
echo " - Deleted node_modules"
|
93 |
echo " - Deleted node_modules"
|
93 |
fi
|
94 |
fi
|
94 |
|
95 |
|
|
|
96 |
|
|
|
97 |
|
95 |
cd ../..
|
98 |
# cd ../..
|
96 |
|
99 |
#
|
97 |
cd ${COMP_BUNDLES_DIR}
|
100 |
# cd ${COMP_BUNDLES_DIR}
|
98 |
COMP_BLOB_SHA1=$(sha1sum ${CODE_ZIP_FILENAME} | awk '{print $1}')
|
101 |
# COMP_BLOB_SHA1=$(sha1sum ${CODE_ZIP_FILENAME} | awk '{print $1}')
|
99 |
createBlobBundle ${BLOB_BUNDLE_COMPONENT_NAME} ${COMP_BLOB_SHA1}
|
102 |
# createBlobBundle ${BLOB_BUNDLE_COMPONENT_NAME} ${COMP_BLOB_SHA1}
|
100 |
echo " - Generated blob manifest"
|
103 |
# echo " - Generated blob manifest"
|
101 |
|
104 |
#
|
102 |
# Create component code blob bundle
|
105 |
# # Create component code blob bundle
|
103 |
zip -r blobBundle_component_${COMPONENT_NAME}.zip Manifest.json ${CODE_ZIP_FILENAME}
|
106 |
# zip -r blobBundle_component_${COMPONENT_NAME}.zip Manifest.json ${CODE_ZIP_FILENAME}
|
104 |
echo " - Generated blob bundle for code: blobBundle_component_${COMPONENT_NAME}.zip"
|
107 |
# echo " - Generated blob bundle for code: blobBundle_component_${COMPONENT_NAME}.zip"
|
105 |
mv Manifest.json Manifest_blob.json
|
108 |
# mv Manifest.json Manifest_blob.json
|
106 |
|
109 |
#
|
107 |
# Create component bundle
|
110 |
# # Create component bundle
|
108 |
cp ${COMP_DIR}/Manifest.json Manifest.json
|
111 |
# cp ${COMP_DIR}/Manifest.json Manifest.json
|
109 |
sed -i -e "s/\"code\"\s*:\s*\".*\"/\"code\": \"${BLOB_BUNDLE_COMPONENT_NAME}\"/g" Manifest.json
|
112 |
# sed -i -e "s/\"code\"\s*:\s*\".*\"/\"code\": \"${BLOB_BUNDLE_COMPONENT_NAME}\"/g" Manifest.json
|
110 |
rm -f component_bundle_${COMPONENT_NAME}.zip
|
113 |
# rm -f component_bundle_${COMPONENT_NAME}.zip
|
111 |
zip -r $BUNDLES_DIR/component_bundle_${COMPONENT_NAME}.zip Manifest.json blobBundle_component_${COMPONENT_NAME}.zip
|
114 |
# zip -r $BUNDLES_DIR/component_bundle_${COMPONENT_NAME}.zip Manifest.json blobBundle_component_${COMPONENT_NAME}.zip
|
112 |
echo " - Generated component bundle: component_bundle_${COMPONENT_NAME}.zip"
|
115 |
# echo " - Generated component bundle: component_bundle_${COMPONENT_NAME}.zip"
|
113 |
rm Manifest.json \
|
116 |
# rm Manifest.json \
|
114 |
blobBundle_component_${COMPONENT_NAME}.zip \
|
117 |
# blobBundle_component_${COMPONENT_NAME}.zip \
|
115 |
Manifest_blob.json \
|
118 |
# Manifest_blob.json \
|
116 |
code.zip
|
119 |
# code.zip
|
117 |
|
120 |
#
|
118 |
# Reset the current directory to the original one
|
121 |
# # Reset the current directory to the original one
|
119 |
cd ${INITIAL_DIR}
|
122 |
# cd ${INITIAL_DIR}
|
120 |
rm -rf ${COMP_BUNDLES_DIR}
|
123 |
# rm -rf ${COMP_BUNDLES_DIR}
|
121 |
echo ""
|
124 |
# echo ""
|
122 |
}
|
125 |
}
|
123 |
|
126 |
|
124 |
|
127 |
|
125 |
function bundleService() {
|
128 |
function bundleService() {
|
126 |
INITIAL_DIR="${PWD}"
|
129 |
INITIAL_DIR="${PWD}"
|