Skip to content

Commit

Permalink
Enh: Build refactoring: BUILD_DEPLOY.sh & BUILD_DOCKER.sh
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
derwok committed Oct 21, 2017
1 parent 59a0c3a commit 7443a34
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 26 deletions.
14 changes: 14 additions & 0 deletions .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
```
37 changes: 37 additions & 0 deletions .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)
21 changes: 4 additions & 17 deletions .docker/BUILD.sh → .docker/BUILD_DOCKER.sh
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -66,4 +53,4 @@ echo "---------"
echo "$pushlist"

#### Clean up
rm -rf 4minitz_bin
# rm -rf ../.deploy/4minitz_bin
2 changes: 1 addition & 1 deletion .docker/Dockerfile
Expand Up @@ -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 \
Expand Down
6 changes: 3 additions & 3 deletions .docker/README.md
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Expand Up @@ -4,6 +4,8 @@
.idea/
.docker/4minitz_settings.json
.docker/4minitz_bin
.deploy/4minitz_bin/

node_modules
npm-debug.log
settings.json
Expand All @@ -14,3 +16,8 @@ public/fonts/glyphicons-halflings-regular.*
*.json.bak

4minitz\.iml


\.deploy/4minitz_bin\.zip

package-lock\.json
51 changes: 51 additions & 0 deletions 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."
8 changes: 4 additions & 4 deletions 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",
Expand Down
2 changes: 1 addition & 1 deletion settings_sample.json
Expand Up @@ -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",
Expand Down

0 comments on commit 7443a34

Please sign in to comment.