summaryrefslogtreecommitdiffstats
path: root/deployment/docker-entrypoint.sh
blob: 0ec8d0ebe37e6ec85cc5799a82820f5d2d553790 (plain)
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
30
31
32
33
#!/bin/bash

function verify_consul_run {
    consul --version
}

function start_consul_server {
    # Running consul in server mode since we are doing a single node. If we need to add more,
    # We need to run multiple consul agents in client mode without providing the -server arguements.

    consul agent -bootstrap -server -bind=127.0.0.1 -data-dir=/dkv/consul &
}

function start_api_server {
    # Uncomment the following after the mountpath is setup in the code base and the docker file.
    # Until then, go run is used.
    #cd target
    #./dkv
    cd src/dkv/
    go run main.go
}

function set_paths {
    export GOPATH=$PWD
    source /etc/environment
}

set_paths
if [ "$CONSUL_IP" = "localhost" ]; then
    start_consul_server
    sleep 5
fi
start_api_server