@@ -6,10 +6,25 @@ containers:
66 NODE_PATH : /usr/local/lib/node_modules
77 NPM_CONFIG_LOGLEVEL : info
88 HOSTNAME_URL : eventsmonkey.itkpi.pp.ua
9+ APP_VERSION_FILE : /.app-version
10+ APP_NAME : Events Parser
911 setup :
1012 - !Ubuntu xenial
1113 - !Env
1214 << : *env_vars
15+ - !Depends .git/index
16+ # Python is a dendency of node-gyp:
17+ # Ref: https://github.com/nodejs/node-gyp#installation
18+ - !BuildDeps [python, git]
19+ - !Install [libexpat1]
20+ # Generate the current version of app
21+ - &generate_app_version !Sh |
22+ ver=`git describe | awk -F- '{print$1}'`-`git rev-parse --abbrev-ref HEAD`
23+ git describe | awk -F- '{print$2"\n"$3}' | while read sub_ver
24+ do
25+ ver=$ver-$sub_ver
26+ done
27+ echo $ver > $APP_VERSION_FILE
1328 # Get and install an official nodejs7 binary
1429 - &install_nodejs_7 !Tar
1530 url : https://nodejs.org/dist/v7.2.1/node-v7.2.1-linux-x64.tar.xz
@@ -21,10 +36,6 @@ containers:
2136 # Ref: vagga.readthedocs.io/en/latest/build_steps.html#step-NpmConfig
2237 - !NpmConfig
2338 install_node : false
24- # Python is a dendency of node-gyp:
25- # Ref: https://github.com/nodejs/node-gyp#installation
26- - !BuildDeps [python]
27- - !Install [libexpat1]
2839 # install dependencies from package.json, see the doc for extra options:
2940 # Ref: vagga.readthedocs.io/en/latest/build_steps.html#step-NpmDependencies
3041 - !NpmDependencies
@@ -35,10 +46,13 @@ containers:
3546 << : *env_vars
3647 setup :
3748 - !Alpine v3.4
38- - !BuildDeps [binutils-gold, curl, g++, gcc, gnupg, libgcc, linux-headers, make, python]
49+ - !BuildDeps [binutils-gold, curl, g++, gcc, gnupg, libgcc, linux-headers, make, python, git ]
3950 - !Install [libstdc++]
4051 - !Env
4152 << : *env_vars
53+ - !Depends .git/index
54+ # Generate the current version of app
55+ - *generate_app_version
4256 # Add a user to make him nodejs files owner:
4357 - !Sh adduser -D -u 1000 node
4458 # Add trusted keys to the gpg registry:
@@ -72,9 +86,13 @@ containers:
7286 << : *env_vars
7387 setup :
7488 - !Alpine v3.4
89+ - !BuildDeps [git]
90+ - !Depends .git/index
7591 - !Install [binutils-gold, curl, g++, gcc, gnupg, libgcc, linux-headers, make, python, libstdc++]
7692 - !Env
7793 << : *env_vars
94+ # Generate the current version of app
95+ - *generate_app_version
7896 - !Download
7997 url : https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub
8098 path : /etc/apk/keys/sgerrand.rsa.pub
@@ -93,6 +111,13 @@ containers:
93111 setup :
94112 - !Alpine v3.4
95113 - !BuildDeps [python, git]
114+ # Catch branch changes
115+ - !Depends .git/index
116+ # Add env vars into build time
117+ - !Env
118+ << : *env_vars
119+ # Generate the current version of app
120+ - *generate_app_version
96121 - !NpmDependencies
97122 file : package.json
98123 environ :
@@ -101,10 +126,24 @@ containers:
101126commands :
102127 run7 : !Command
103128 container : nodejs-7-ubuntu-bin
104- run : npm start
129+ # add current version of the app to env vars
130+ run : |
131+ export APP_VERSION=`cat $APP_VERSION_FILE`
132+ npm start
105133 test : !Command
106134 container : nodejs-7-ubuntu-bin
107135 run : [standard]
108136 run : !Command
109137 container : eventsparser
110- run : npm start
138+ # add current version of the app to env vars
139+ run : |
140+ export APP_VERSION=`cat $APP_VERSION_FILE`
141+ npm start
142+ version : !Command
143+ container : nodejs-7-ubuntu-bin
144+ # add current version of the app to env vars
145+ run : |
146+ export APP_VERSION=`cat $APP_VERSION_FILE`
147+ echo -n $APP_NAME 'version: ' >&2
148+ echo -n $APP_VERSION
149+ echo >&2
0 commit comments