diff options
author | Shashank Kumar Shankar <shashank.kumar.shankar@intel.com> | 2018-02-27 15:41:46 -0800 |
---|---|---|
committer | Shashank Kumar Shankar <shashank.kumar.shankar@intel.com> | 2018-03-07 13:40:18 -0800 |
commit | 5031a4e20a281b7a94f8c3743b1572314c574ec4 (patch) | |
tree | 7072a5d16dc948b35b8a6a76764056c6e4bab003 /deployment | |
parent | 67dd59385cf983ef1307e3b3e410a8f773d8a5c3 (diff) |
Add Docker building scripts and update swagger
This patch adds scripts to build Docker container and
updates swagger API doc.
Change-Id: Ifb10d483946112e38d716c9ae07995ffeb14d2d3
Issue-ID: MUSIC-41
Signed-off-by: Shashank Kumar Shankar <shashank.kumar.shankar@intel.com>
Diffstat (limited to 'deployment')
-rw-r--r-- | deployment/Dockerfile | 43 | ||||
-rw-r--r-- | deployment/docker-build.sh | 11 | ||||
-rw-r--r-- | deployment/docker-entrypoint.sh | 33 | ||||
-rw-r--r-- | deployment/run.sh | 6 | ||||
-rw-r--r-- | deployment/setup-dependency.sh | 30 |
5 files changed, 123 insertions, 0 deletions
diff --git a/deployment/Dockerfile b/deployment/Dockerfile new file mode 100644 index 0000000..7f6c6d5 --- /dev/null +++ b/deployment/Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu:14.04 + +ARG HTTP_PROXY=${HTTP_PROXY} +ARG HTTPS_PROXY=${HTTPS_PROXY} + +ENV http_proxy $HTTP_PROXY +ENV https_proxy $HTTPS_PROXY +ENV CONSUL_IP $CONSUL_IP +ENV CONSUL_VERSION 1.0.6 + +# Run Docker build from dkv directory. +WORKDIR /distributed-kv-store + +RUN apt-get update && \ + apt-get install -y build-essential && \ + apt-get install -y realpath && \ + apt-get install -y unzip && \ + apt-get install -y git && \ + apt-get install -y curl && \ + apt-get install -y wget && \ + git clone https://git.onap.org/music/distributed-kv-store + + +RUN wget -qO /tmp/consul.zip "https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip" && \ + unzip -d /bin /tmp/consul.zip && \ + chmod 755 /bin/consul && \ + rm /tmp/consul.zip + +EXPOSE 8200 +EXPOSE 8080 + +# Change this when deployment gets merged. +WORKDIR /distributed-kv-store/distributed-kv-store/deployment/ +ADD ./setup-dependency.sh /distributed-kv-store/distributed-kv-store/deployment/ +ADD ./docker-entrypoint.sh /distributed-kv-store/distributed-kv-store/deployment/ + +WORKDIR /distributed-kv-store/distributed-kv-store +RUN deployment/setup-dependency.sh + +VOLUME /configs + +ENTRYPOINT deployment/docker-entrypoint.sh +#ENTRYPOINT /bin/bash
\ No newline at end of file diff --git a/deployment/docker-build.sh b/deployment/docker-build.sh new file mode 100644 index 0000000..767554f --- /dev/null +++ b/deployment/docker-build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +if [ $HTTP_PROXY ]; then + BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}" +fi +if [ $HTTPS_PROXY ]; then + BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}" +fi + +echo "Start build docker image" +docker build ${BUILD_ARGS} -t dkv . diff --git a/deployment/docker-entrypoint.sh b/deployment/docker-entrypoint.sh new file mode 100644 index 0000000..9b29e3e --- /dev/null +++ b/deployment/docker-entrypoint.sh @@ -0,0 +1,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. + + # CHANGE THIS TO SERVER MODE! + # consul agent -dev > /dev/null 2>&1 & + 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 +start_consul_server +sleep 5 +start_api_server diff --git a/deployment/run.sh b/deployment/run.sh new file mode 100644 index 0000000..1aae1f6 --- /dev/null +++ b/deployment/run.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +CONSUL_IP="localhost" +MOUNTPATH="/configs" + +docker run -e CONSUL_IP=$CONSUL_IP -e MOUNTPATH=$MOUNTPATH -it --name dkv -p 8200:8200 -p 8080:8080 dkv diff --git a/deployment/setup-dependency.sh b/deployment/setup-dependency.sh new file mode 100644 index 0000000..fcb2d51 --- /dev/null +++ b/deployment/setup-dependency.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +function install_go { + local golang_version=go1.10.linux-amd64 + if [ ! -d /opt/go ]; then + mkdir /opt/go + pushd /opt/go + curl -O https://dl.google.com/go/$golang_version.tar.gz + tar -zxf $golang_version.tar.gz + echo GOROOT=$PWD/go >> /etc/environment + echo PATH=$PATH:$PWD/go/bin >> /etc/environment + rm -rf tar -zxf $golang_version.tar.gz + popd + fi + source /etc/environment +} + +function install_dependencies { + pushd src/dkv/ + make all + popd +} + +function create_mountpath { + cp -r mountpath/ /configs +} + +install_go +install_dependencies +create_mountpath |