forked from garystafford/virtual-vehicles-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_compose.sh
29 lines (23 loc) · 1.07 KB
/
build_compose.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
########################################################################
#
# title: Docker Compose YAML Template Variable Substitution Script
# author: Gary A. Stafford (https://programmaticponderings.com)
# url: https://github.com/garystafford/virtual-vehicles-docker
# description: Replaces tokens in template and create docker-compose.yml
#
# to run: sh run_comppse.sh
#
########################################################################
# reference: http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/
# http://www.cyberciti.biz/faq/howto-sed-substitute-find-replace-multiple-patterns/
base_url_token="{{ base_url }}"
base_url="api.virtual-vehicles.com" # url of public rest api
host_ip_token="{{ host_ip }}"
host_ip=$(docker-machine ip $(docker-machine active)) # ip of host
echo " ${base_url_token} = ${base_url}"
echo " ${host_ip_token} = ${host_ip}"
sed -e "s/${base_url_token}/${base_url}/g" \
-e "s/${host_ip_token}/${host_ip}/g" \
< docker-compose-template-v2.yml \
> docker-compose.yml