diff options
author | Lauri Ojansivu <x@xet7.org> | 2018-12-18 19:40:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-18 19:40:44 +0200 |
commit | 51a19878dd761035a3c0a201a42537c583d8da77 (patch) | |
tree | 90ba91dac8d27b346275101f02a9a6a6d1eccd02 /stacksmith/user-scripts | |
parent | ddca6a1ad84944af43dc858c573dbaedf469eb1a (diff) | |
parent | cac74122f204bfb13e9e277901b9a385c75f4135 (diff) | |
download | wekan-51a19878dd761035a3c0a201a42537c583d8da77.tar.gz wekan-51a19878dd761035a3c0a201a42537c583d8da77.tar.bz2 wekan-51a19878dd761035a3c0a201a42537c583d8da77.zip |
Merge pull request #2064 from j-fuentes/devel
Add Bitnami Stacksmith
Diffstat (limited to 'stacksmith/user-scripts')
-rwxr-xr-x | stacksmith/user-scripts/boot.sh | 21 | ||||
-rwxr-xr-x | stacksmith/user-scripts/build.sh | 86 | ||||
-rwxr-xr-x | stacksmith/user-scripts/run.sh | 20 |
3 files changed, 127 insertions, 0 deletions
diff --git a/stacksmith/user-scripts/boot.sh b/stacksmith/user-scripts/boot.sh new file mode 100755 index 00000000..bd95102f --- /dev/null +++ b/stacksmith/user-scripts/boot.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -euxo pipefail + +# This file will store the config env variables needed by the app +readonly CONF=/build/env.config + +# EMAIL_URL can also be set here by injecting another env variable in the template +# ROOT_URL can also be set at runtime, by querying AWS api or by using ingress annotations in the template for k8s. + +cat >"${CONF}" <<'EOF' +export MONGO_URL=mongodb://{{DATABASE_USER}}:{{DATABASE_PASSWORD}}@{{DATABASE_HOST}}:{{DATABASE_PORT}}/{{DATABASE_NAME}} +export ROOT_URL=http://localhost +export PORT=3000 +EOF + +sed -i -e "s/{{DATABASE_USER}}/${DATABASE_USER}/" "${CONF}" +sed -i -e "s/{{DATABASE_PASSWORD}}/${DATABASE_PASSWORD}/" "${CONF}" +sed -i -e "s/{{DATABASE_HOST}}/${DATABASE_HOST}/" "${CONF}" +sed -i -e "s/{{DATABASE_PORT}}/${DATABASE_PORT}/" "${CONF}" +sed -i -e "s/{{DATABASE_NAME}}/${DATABASE_NAME}/" "${CONF}" + diff --git a/stacksmith/user-scripts/build.sh b/stacksmith/user-scripts/build.sh new file mode 100755 index 00000000..a8f756e6 --- /dev/null +++ b/stacksmith/user-scripts/build.sh @@ -0,0 +1,86 @@ +#!/bin/bash +set -euxo pipefail + +BUILD_DEPS="bsdtar gnupg wget curl bzip2 python git ca-certificates perl-Digest-SHA" +NODE_VERSION=v8.14.0 +METEOR_RELEASE=1.6.0.1 +USE_EDGE=false +METEOR_EDGE=1.5-beta.17 +NPM_VERSION=latest +FIBERS_VERSION=2.0.0 +ARCHITECTURE=linux-x64 +NODE_VERSION=v10.14.1 + +sudo yum groupinstall -y 'Development Tools' +sudo yum install -y http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm +sudo yum install -y git + +sudo useradd --user-group --system --home-dir /home/wekan wekan +sudo mkdir -p /home/wekan +sudo chown wekan:wekan /home/wekan/ + +sudo -u wekan git clone https://github.com/j-fuentes/wekan.git /home/wekan/app + +sudo yum install -y ${BUILD_DEPS} + +# Meteor installer doesn't work with the default tar binary, so using bsdtar while installing. +# https://github.com/coreos/bugs/issues/1095#issuecomment-350574389 +sudo cp $(which tar) $(which tar)~ +sudo ln -sf $(which bsdtar) $(which tar) + +# Install nodejs +wget https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz +wget https://nodejs.org/dist/${NODE_VERSION}/SHASUMS256.txt.asc + +grep ${NODE_VERSION}-${ARCHITECTURE}.tar.gz SHASUMS256.txt.asc | shasum -a 256 -c - + +tar xvzf node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz +rm node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz +sudo mv node-${NODE_VERSION}-${ARCHITECTURE} /opt/nodejs +sudo rm -f /usr/bin/node +sudo rm -f /usr/bin/npm +sudo ln -s /opt/nodejs/bin/node /usr/bin/node || true +sudo ln -s /opt/nodejs/bin/npm /usr/bin/npm || true + +sudo npm install -g npm@${NPM_VERSION} +sudo npm install -g node-gyp +sudo npm install -g --unsafe-perm fibers@${FIBERS_VERSION} + +cd /home/wekan + +#install meteor +sudo curl "https://install.meteor.com" -o /home/wekan/install_meteor.sh +sudo chmod +x /home/wekan/install_meteor.sh +sudo sed -i 's/VERBOSITY="--silent"/VERBOSITY="--progress-bar"/' ./install_meteor.sh +echo "Starting meteor ${METEOR_RELEASE} installation... \n" + +# Check if opting for a release candidate instead of major release +if [ "$USE_EDGE" = false ]; then + sudo su -c '/home/wekan/install_meteor.sh' - wekan +else + sudo -u wekan git clone --recursive --depth 1 -b release/METEOR@${METEOR_EDGE} git://github.com/meteor/meteor.git /home/wekan/.meteor; +fi; + +# Get additional packages +sudo mkdir -p /home/wekan/app/packages +sudo chown wekan:wekan --recursive /home/wekan/app +cd /home/wekan/app/packages +sudo -u wekan git clone --depth 1 -b master git://github.com/wekan/flow-router.git kadira-flow-router +sudo -u wekan git clone --depth 1 -b master git://github.com/meteor-useraccounts/core.git meteor-useraccounts-core +sudo -u wekan git clone --depth 1 -b master git://github.com/wekan/meteor-accounts-cas.git +sudo -u wekan git clone --depth 1 -b master git://github.com/wekan/wekan-ldap.git +sudo sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' /home/wekan/app/packages/meteor-useraccounts-core/package.js +sudo -u wekan /home/wekan/.meteor/meteor -- help + +# Build app +cd /home/wekan/app +meteor=/home/wekan/.meteor/meteor +sudo -u wekan ${meteor} add standard-minifier-js +sudo -u wekan ${meteor} npm install +sudo -u wekan ${meteor} build --directory /home/wekan/app_build +sudo cp /home/wekan/app/fix-download-unicode/cfs_access-point.txt /home/wekan/app_build/bundle/programs/server/packages/cfs_access-point.js +sudo chown wekan:wekan /home/wekan/app_build/bundle/programs/server/packages/cfs_access-point.js +cd /home/wekan/app_build/bundle/programs/server/ +sudo npm install +sudo chown -R wekan:wekan ./node_modules +sudo mv /home/wekan/app_build/bundle /build diff --git a/stacksmith/user-scripts/run.sh b/stacksmith/user-scripts/run.sh new file mode 100755 index 00000000..2aea7ea0 --- /dev/null +++ b/stacksmith/user-scripts/run.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -euo pipefail + +readonly CONF=/build/env.config + +source ${CONF} + +# wait for DB +check_db() { + mongo $MONGO_URL --eval "db.runCommand( { connectionStatus: 1} )" --quiet | python -c 'import json,sys;obj=json.load(sys.stdin);code = 0 if obj["ok"]==1 else 1; sys.exit(code);' +} +until check_db; do + period=5 + echo "Cannot connect to db, waiting ${period} seconds before trying again..." + sleep ${period} +done + +cd /build +echo "starting the wekan service..." +node main.js |