Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add install script to fetch combined node_modules folder #66

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scripts/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
"mounts": {
"service": "/data/service"
}
},
{
"documentation": {
"command": "install",
"description": "installs combined node modules of service and template",
"arguments": []
},
"environment": {
"image": "semtech/mu-javascript-template:1.8.0",
"interactive": false,
"script": "install/run.sh"
},
"mounts": {
"service": "/data/service"
}
}
]
}
48 changes: 48 additions & 0 deletions scripts/install/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
source /usr/src/app/helpers.sh

if [ ! -f /data/service/package.json ]
then
echo "No package.json found in service. Nothing to do."
exit 1;
fi

echo "Removing node_modules from service"
cd /data/service/
rm -rf node_modules

echo "Running template npm install"
cd /usr/src/app/
rm -rf /usr/src/app/node_modules

npm install

echo "Moving service code"
# move our service code to the app folder. In theory we only need the package.json and package-lock.json files
docker-rsync /data/service/ /usr/src/app/app/
rm -rf /usr/src/app/app/node_modules

# sync the node modules of template to service directory.
# do this after we took the service code to not take them with us
docker-rsync /usr/src/app/node_modules /data/service/

cd /usr/src/app/app/

echo "Running service npm install"
npm install

# sync the node modules of app to service directory
docker-rsync /usr/src/app/app/node_modules/ /data/service/node_modules/

cd /usr/src/app/

echo "Generating mu module"

mkdir /usr/src/app/built-mu
/usr/src/app/node_modules/.bin/babel \
/usr/src/app/helpers/mu/ \
--source-maps true \
--out-dir /usr/src/app/built-mu \
--extensions ".js"

cp -R /usr/src/app/built-mu /data/service/node_modules/mu