Add a config file feature(.build.env).
Showing
1 changed file
with
38 additions
and
5 deletions
... | @@ -2,10 +2,6 @@ | ... | @@ -2,10 +2,6 @@ |
2 | 2 | ||
3 | set -e | 3 | set -e |
4 | 4 | ||
5 | TAG=test-latest | ||
6 | APP=moqui-app | ||
7 | PUSH_TO=docker://5.161.91.120:31234 | ||
8 | PREFIX= | ||
9 | declare -a images=(moqui-jdbc-drivers moqui-app) | 5 | declare -a images=(moqui-jdbc-drivers moqui-app) |
10 | 6 | ||
11 | TOP_DIR="$(cd "$(dirname "$0")"; pwd -P)" | 7 | TOP_DIR="$(cd "$(dirname "$0")"; pwd -P)" |
... | @@ -23,6 +19,11 @@ _push() { | ... | @@ -23,6 +19,11 @@ _push() { |
23 | done | 19 | done |
24 | } | 20 | } |
25 | 21 | ||
22 | APP=moqui-app | ||
23 | OVERRIDE_TAG= | ||
24 | DEVELOPER= | ||
25 | PUSH_TO= | ||
26 | PREFIX= | ||
26 | while [[ $# -gt 0 ]]; do | 27 | while [[ $# -gt 0 ]]; do |
27 | case "$1" in | 28 | case "$1" in |
28 | (--app) | 29 | (--app) |
... | @@ -38,7 +39,11 @@ while [[ $# -gt 0 ]]; do | ... | @@ -38,7 +39,11 @@ while [[ $# -gt 0 ]]; do |
38 | shift 2 | 39 | shift 2 |
39 | ;; | 40 | ;; |
40 | (--tag) | 41 | (--tag) |
41 | TAG="$2" | 42 | OVERRIDE_TAG="$2" |
43 | shift 2 | ||
44 | ;; | ||
45 | (--developer) | ||
46 | DEVELOPER="$2" | ||
42 | shift 2 | 47 | shift 2 |
43 | ;; | 48 | ;; |
44 | (*) | 49 | (*) |
... | @@ -46,6 +51,34 @@ while [[ $# -gt 0 ]]; do | ... | @@ -46,6 +51,34 @@ while [[ $# -gt 0 ]]; do |
46 | ;; | 51 | ;; |
47 | esac | 52 | esac |
48 | done | 53 | done |
54 | |||
55 | declare -A build_env=() | ||
56 | |||
57 | if [[ -f $APP/.build.env ]]; then | ||
58 | set -x | ||
59 | while read line; do | ||
60 | [[ $line = ^"#".* ]] && continue | ||
61 | if [[ $line =~ ^\s*(.*?)\s*=\s*(.*?)\s*$ ]]; then | ||
62 | build_env[${BASH_REMATCH[1]}]="${BASH_REMATCH[2]}" | ||
63 | fi | ||
64 | done < "$APP/.build.env" | ||
65 | set +x | ||
66 | fi | ||
67 | [[ -z $OVERRIDE_TAG ]] && OVERRIDE_TAG="${build_env["override-tag"]}" | ||
68 | [[ -z $DEVELOPER ]] && DEVELOPER="${build_env["developer"]}" | ||
69 | [[ -z $PREFIX ]] && PREFIX="${build_env["prefix"]}" | ||
70 | [[ -z $PUSH_TO ]] && PUSH_TO="${build_env["push-to"]}" | ||
71 | |||
72 | if [[ $OVERRIDE_TAG ]]; then | ||
73 | TAG="$OVERRIDE_TAG" | ||
74 | elif [[ -e $APP/.git ]]; then | ||
75 | TAG="$(GIT_DIR="$APP/.git" git branch --show-current)" | ||
76 | else | ||
77 | TAG=test-latest | ||
78 | fi | ||
79 | if [[ $DEVELOPER ]]; then | ||
80 | TAG+="-$DEVELOPER" | ||
81 | fi | ||
49 | case "$1" in | 82 | case "$1" in |
50 | (build) | 83 | (build) |
51 | _build | 84 | _build | ... | ... |
-
Please register or sign in to post a comment