From 7443a346b9586352f1ee22cd1d495fb87883f2b0 Mon Sep 17 00:00:00 2001 From: Wolfram Esser Date: Sat, 21 Oct 2017 23:41:04 +0200 Subject: [PATCH] Enh: Build refactoring: BUILD_DEPLOY.sh & BUILD_DOCKER.sh Refactored "/BUILD_DEPLOY.sh" out of ".docker/BUILD_DOCKER.sh" to allow us build-only (without docker). So we can e.g. upload x86_64 ready-to-run ZIP to github. No docker needed in this case. Docker is often not possible in VM environments on shared servers. Instead, MongoDB & Node 4.8.4 are the dependencies now. --- .deploy/README.md | 14 ++++++++ .deploy/run_sample.sh | 37 +++++++++++++++++++ .docker/{BUILD.sh => BUILD_DOCKER.sh} | 21 +++-------- .docker/Dockerfile | 2 +- .docker/README.md | 6 ++-- .gitignore | 7 ++++ BUILD_DEPLOY.sh | 51 +++++++++++++++++++++++++++ package.json | 8 ++--- settings_sample.json | 2 +- 9 files changed, 122 insertions(+), 26 deletions(-) create mode 100644 .deploy/README.md create mode 100755 .deploy/run_sample.sh rename .docker/{BUILD.sh => BUILD_DOCKER.sh} (73%) create mode 100755 BUILD_DEPLOY.sh diff --git a/.deploy/README.md b/.deploy/README.md new file mode 100644 index 000000000..e22f93afd --- /dev/null +++ b/.deploy/README.md @@ -0,0 +1,14 @@ +# 4Minitz .deploy directory + +You can build a 4Minitz server here by running from the project root: + +``` +./BUILD_DEPLOY.sh +``` + +Afterwards you may run a 4Minitz server by: + +``` +cd .deploy/4minitz_bin +./run.sh +``` diff --git a/.deploy/run_sample.sh b/.deploy/run_sample.sh new file mode 100755 index 000000000..c0273bae4 --- /dev/null +++ b/.deploy/run_sample.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +echo "You must adapt the below environment vars in this script to your needs!" +echo "Then remove the following exit command" +echo "Exiting now!" +exit + +############### Environment configuration ###### +# Connection to your mongodb server (please ensure password protection and encrypted communication!) +export MONGO_URL='mongodb://USER:PASSWORD@localhost:27017/' +# Port for your 4Minitz server +export PORT=3100 +# Port to your 4Minitz root URL (to generate correct links in EMails) +# the leading http:// or https:// is IMPORTANT! +export ROOT_URL='http://localhost:3100' +# Read in your settings.json +export METEOR_SETTINGS=$(cat ./settings.json) +################################################# + +#### Check if installed node version matches the node build version +nodeversionbuild=`cat ./bundle/.node_version.txt` +nodeversionnow=`node --version` +if [ ${nodeversionbuild} != ${nodeversionnow} ] +then + echo " " + echo "*** WARNING!" + echo " Node version mismatch:" + echo " Node version on build: ${nodeversionbuild}" + echo " Node version now : ${nodeversionnow}" + echo "If app has launch errors, use node version manager:" + echo " nvm install ${nodeversionbuild} && nvm use ${nodeversionbuild}" + echo " " + sleep 5 +fi + +#### Launch the 4Minitz server +(cd bundle && node main.js) diff --git a/.docker/BUILD.sh b/.docker/BUILD_DOCKER.sh similarity index 73% rename from .docker/BUILD.sh rename to .docker/BUILD_DOCKER.sh index d737d0d5e..006d7680a 100755 --- a/.docker/BUILD.sh +++ b/.docker/BUILD_DOCKER.sh @@ -4,7 +4,7 @@ dockerproject=4minitz/4minitz commitshort=$(git rev-parse --short HEAD 2> /dev/null | sed "s/\(.*\)/\1/") baseimagetag=$dockerproject:gitcommit-$commitshort -echo "Usage: ./BUILD.sh [--imagename USER/IMAGE] [LIST OF TAGS]" +echo "Usage: ./BUILD_DOCKER.sh [--imagename USER/IMAGE] [LIST OF TAGS]" echo " e.g.: ./BUILD.sh master stable latest 0.9.1" echo " e.g.: ./BUILD.sh develop unstable" echo " e.g.: ./BUILD.sh --imagename johndoe/4minitz master stable latest 0.9.1" @@ -20,11 +20,6 @@ echo "Docker Project : '$dockerproject'" echo "Target Base Image: '$baseimagetag'" echo "" -#### Patch package.json with current git branch & version -pushd ../private -./releasePrep.sh -popd - #### Prepare settings.json settingsfile=./4minitz_settings.json cp ../settings_sample.json $settingsfile @@ -35,19 +30,11 @@ sed -i '' 's/"mongodumpTargetDirectory": "[^\"]*"/"mongodumpTargetDirectory": "\ sed -i '' 's/"storagePath": "[^\"]*"/"storagePath": "\/4minitz_storage\/attachments"/' $settingsfile sed -i '' 's/"targetDocPath": "[^\"]*"/"targetDocPath": "\/4minitz_storage\/protocols"/' $settingsfile - #### Build 4Minitz with meteor -cd .. # pwd => "/" of 4minitz project -mkdir .docker/4minitz_bin -meteor npm install -meteor build .docker/4minitz_bin --directory -# Our package.json will not be available - unless we copy it over to the image -cp package.json .docker/4minitz_bin/bundle/programs/server/package4min.json -cd .docker/4minitz_bin/bundle/programs/server || exit 1 -meteor npm install --production +(cd .. && ./BUILD_DEPLOY.sh) +mv ../.deploy/4minitz_bin . || exit 1 #### Build 4Minitz docker image -cd ../../../.. || exit 1 # pwd => .docker docker build --no-cache -t "$baseimagetag" . echo "--------- CCPCL: The 'Convenience Copy&Paste Command List'" echo "docker push $baseimagetag" @@ -66,4 +53,4 @@ echo "---------" echo "$pushlist" #### Clean up -rm -rf 4minitz_bin +# rm -rf ../.deploy/4minitz_bin diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 6ffd421a2..7d7c13919 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -4,7 +4,7 @@ MAINTAINER 4Minitz-Team <4minitz@gmx.de> #### Install Node.js ENV NPM_CONFIG_LOGLEVEL info -ENV NODE_VERSION 4.7.3 +ENV NODE_VERSION 4.8.4 RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node \ diff --git a/.docker/README.md b/.docker/README.md index 86f26c1e5..520817f5b 100644 --- a/.docker/README.md +++ b/.docker/README.md @@ -8,9 +8,9 @@ that are officially supported by docker. 1. Install [docker](https://docs.docker.com/engine/installation/) 1. Inside the '.docker' directory run `./BUILD.sh` with an optional list of tags. E.g.: ```` - ./BUILD.sh 0 0.8 0.8.1 master stable latest - ./BUILD.sh 0.9.x develop unstable edge - ./BUILD.sh --imagename johndoe/4minitzdemo 0.9.x develop unstable edge + ./BUILD_DOCKER.sh 0 0.8 0.8.1 master stable latest + ./BUILD_DOCKER.sh 0.9.x develop unstable edge + ./BUILD_DOCKER.sh --imagename johndoe/4minitzdemo 0.9.x develop unstable edge ```` 1. Push the tagged images to docker hub diff --git a/.gitignore b/.gitignore index 38f2d30b8..405be6c35 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ .idea/ .docker/4minitz_settings.json .docker/4minitz_bin +.deploy/4minitz_bin/ + node_modules npm-debug.log settings.json @@ -14,3 +16,8 @@ public/fonts/glyphicons-halflings-regular.* *.json.bak 4minitz\.iml + + +\.deploy/4minitz_bin\.zip + +package-lock\.json diff --git a/BUILD_DEPLOY.sh b/BUILD_DEPLOY.sh new file mode 100755 index 000000000..2f3098394 --- /dev/null +++ b/BUILD_DEPLOY.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +commitshort=$(git rev-parse --short HEAD 2> /dev/null | sed "s/\(.*\)/\1/") + +echo "Usage: ./BUILD_DEPLOY.sh" + +echo "Building for commit ${commitshort} into .deploy/ directory" +#### Clean u +rm -rf .deploy/4minitz_bin/bundle/ + +#### Patch package.json with current git branch & version +(cd ./private && ./releasePrep.sh) + +#### Build 4Minitz with meteor +mkdir .deploy/4minitz_bin +meteor npm install +meteor build .deploy/4minitz_bin --directory + +# Our package.json will not be available - unless we copy it over to the image +# We'll need it for proper version info in the "About" dialog +cp package.json .deploy/4minitz_bin/bundle/programs/server/package4min.json +(cd .deploy/4minitz_bin/bundle/programs/server && meteor npm install --production) + +#### Prepare settings.json +settingsfile=.deploy/4minitz_bin/settings.json +if [ -f "${settingsfile}" ] +then + echo "settings.json found: ${settingsfile}" + echo "We'll keep it!" +else + cp ./settings_sample.json $settingsfile + echo "Patching $settingsfile" + sed -i '' 's/"ROOT_URL": "[^\"]*"/"ROOT_URL": "http:\/\/localhost:3100"/' $settingsfile + sed -i '' 's/"topLeftLogoHTML": "[^\"]*"/"topLeftLogoHTML": "4Minitz"/' $settingsfile + sed -i '' 's/"mongodumpTargetDirectory": "[^\"]*"/"mongodumpTargetDirectory": "\.\.\/\.\.\/\.\.\/4minitz_storage\/mongodump"/' $settingsfile + sed -i '' 's/"storagePath": "[^\"]*"/"storagePath": "\.\.\/\.\.\/\.\.\/4minitz_storage\/attachments"/' $settingsfile + sed -i '' 's/"targetDocPath": "[^\"]*"/"targetDocPath": "\.\.\/\.\.\/\.\.\/4minitz_storage\/protocols"/' $settingsfile +fi + + +#### run.sh & settings.json +runfile=.deploy/4minitz_bin/run.sh +if [ -f "${runfile}" ] +then + echo "run.sh found: ${runfile}" + echo "We'll keep it!" +else + cp ./.deploy/run_sample.sh ${runfile} +fi + +echo "Done." diff --git a/package.json b/package.json index 8f28437ab..aaac1ef3d 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "4Minitz", - "version": "v1.0.2-develop", + "version": "v1.1.0-develop", "4minitz": { "//": "This is some app specific info", "4m_branch": "develop", - "4m_commitlong": "62485c62c6949e99f48ffd8b1de929ab66a4c99e", - "4m_commitshort": "62485c62", - "4m_releasedate": "2017-09-26" + "4m_commitlong": "a576159fe24460f0befdd278328a96f1fb224e1c", + "4m_commitshort": "a576159f", + "4m_releasedate": "2017-10-20" }, "description": "Simply the best free webapp for taking meeting minutes. ;-)", "main": "4minitz.html", diff --git a/settings_sample.json b/settings_sample.json index 02fb9dd94..667c7e25b 100644 --- a/settings_sample.json +++ b/settings_sample.json @@ -188,7 +188,7 @@ "docGeneration": { "enabled": true, - "format": "pdf", + "format": "html", "targetDocPath": "4minitz_storage/protocols", "pathToWkhtmltopdf": "/usr/local/bin/wkhtmltopdf", "wkhtmltopdfParameters" : "--no-outline --print-media-type --no-background",