summaryrefslogtreecommitdiffstats
path: root/deployment
diff options
context:
space:
mode:
authorShashank Kumar Shankar <shashank.kumar.shankar@intel.com>2018-03-15 15:21:15 -0700
committerShashank Kumar Shankar <shashank.kumar.shankar@intel.com>2018-03-16 16:24:27 -0700
commit1f99187b2ec49a132bd82b40bc4cd02d79cbd416 (patch)
treebc8d9cabc08f75be66139b85f9561b1066c89dc3 /deployment
parentb1be54648978a1c858d2ce1e0701e0552c9296fe (diff)
Add Docker push to nexus support
This patch adds support to push built docker container to Nexus. Change-Id: I9c9d3c01c548c0d3dcfec70f299765f0221379dc Issue-ID: MUSIC-59 Signed-off-by: Shashank Kumar Shankar <shashank.kumar.shankar@intel.com>
Diffstat (limited to 'deployment')
-rw-r--r--deployment/Dockerfile39
-rw-r--r--deployment/Dockerfile_ubuntu37
-rwxr-xr-xdeployment/docker-build.sh36
-rwxr-xr-xdeployment/docker-entrypoint.sh23
-rwxr-xr-xdeployment/run.sh8
-rwxr-xr-xdeployment/setup-dependency.sh23
6 files changed, 97 insertions, 69 deletions
diff --git a/deployment/Dockerfile b/deployment/Dockerfile
index 7f6c6d5..e9fe30d 100644
--- a/deployment/Dockerfile
+++ b/deployment/Dockerfile
@@ -1,4 +1,4 @@
-FROM ubuntu:14.04
+FROM alpine:3.7
ARG HTTP_PROXY=${HTTP_PROXY}
ARG HTTPS_PROXY=${HTTPS_PROXY}
@@ -8,18 +8,14 @@ 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 apk update && \
+ apk add g++ && \
+ apk add make && \
+ apk add unzip && \
+ apk add git && \
+ apk add curl && \
+ apk add wget && \
+ apk add --no-cache bash
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 && \
@@ -29,15 +25,14 @@ RUN wget -qO /tmp/consul.zip "https://releases.hashicorp.com/consul/${CONSUL_VER
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
+RUN mkdir /dkv_mount_path && \
+ mkdir /dkv_mount_path/consul_data && \
+ mkdir /dkv_mount_path/configs && \
+ mkdir /dkv_mount_path/configs/default
-VOLUME /configs
+WORKDIR /dkv_mount_path
+ADD ./dkv /dkv_mount_path/
+ADD ./docker-entrypoint.sh /dkv_mount_path/
-ENTRYPOINT deployment/docker-entrypoint.sh
-#ENTRYPOINT /bin/bash \ No newline at end of file
+ENTRYPOINT /dkv_mount_path/docker-entrypoint.sh \ No newline at end of file
diff --git a/deployment/Dockerfile_ubuntu b/deployment/Dockerfile_ubuntu
new file mode 100644
index 0000000..f876805
--- /dev/null
+++ b/deployment/Dockerfile_ubuntu
@@ -0,0 +1,37 @@
+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 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
+
+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
+
+RUN mkdir /dkv_mount_path && \
+ mkdir /dkv_mount_path/consul_data && \
+ mkdir /dkv_mount_path/configs && \
+ mkdir /dkv_mount_path/configs/default
+
+WORKDIR /dkv_mount_path
+ADD ./dkv /dkv_mount_path/
+ADD ./docker-entrypoint.sh /dkv_mount_path/
+
+ENTRYPOINT /dkv_mount_path/docker-entrypoint.sh
+#ENTRYPOINT /bin/bash \ No newline at end of file
diff --git a/deployment/docker-build.sh b/deployment/docker-build.sh
index 767554f..50a2a89 100755
--- a/deployment/docker-build.sh
+++ b/deployment/docker-build.sh
@@ -1,5 +1,14 @@
#!/bin/bash
+BUILD_ARGS="--no-cache"
+ORG="onap"
+VERSION="1.0.0"
+PROJECT="music"
+IMAGE="distributed-kv-store"
+DOCKER_REPOSITORY="nexus3.onap.org:10003"
+IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/${IMAGE}"
+TIMESTAMP=$(date +"%Y%m%dT%H%M%S")
+
if [ $HTTP_PROXY ]; then
BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
fi
@@ -7,5 +16,28 @@ if [ $HTTPS_PROXY ]; then
BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
fi
-echo "Start build docker image"
-docker build ${BUILD_ARGS} -t dkv .
+function generate_binary {
+ pushd ../src/dkv
+ make build
+ popd
+ cp ../target/dkv .
+}
+
+function build_image {
+ echo "Start build docker image."
+ docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest .
+}
+
+function push_image {
+ echo "Start push docker image."
+ docker push ${IMAGE_NAME}:latest
+}
+
+function remove_binary {
+ rm dkv
+}
+
+generate_binary
+build_image
+push_image
+remove_binary
diff --git a/deployment/docker-entrypoint.sh b/deployment/docker-entrypoint.sh
index 0ec8d0e..62cf23b 100755
--- a/deployment/docker-entrypoint.sh
+++ b/deployment/docker-entrypoint.sh
@@ -1,31 +1,14 @@
#!/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 &
+ consul agent -bootstrap -server -bind=127.0.0.1 -data-dir=/dkv_mount_path/consul_data &
}
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
+ pushd /dkv_mount_path/
+ ./dkv
}
-set_paths
if [ "$CONSUL_IP" = "localhost" ]; then
start_consul_server
sleep 5
diff --git a/deployment/run.sh b/deployment/run.sh
index 2451ef9..1be2ef2 100755
--- a/deployment/run.sh
+++ b/deployment/run.sh
@@ -1,6 +1,10 @@
#!/bin/bash
CONSUL_IP="localhost"
-MOUNTPATH="/configs/"
+MOUNTPATH="/dkv_mount_path/configs/"
+DEFAULT_CONFIGS=$(pwd)/../mountpath/default # TODO(sshank): Change this to think from Kubernetes Volumes perspective.
-docker run -e CONSUL_IP=$CONSUL_IP -e MOUNTPATH=$MOUNTPATH -it --name dkv -p 8200:8200 -p 8080:8080 dkv
+docker run -e CONSUL_IP=$CONSUL_IP -e MOUNTPATH=$MOUNTPATH -it \
+ --name dkv \
+ -v $DEFAULT_CONFIGS:/dkv_mount_path/configs/default \
+ -p 8200:8200 -p 8080:8080 nexus3.onap.org:10003/onap/music/distributed-kv-store
diff --git a/deployment/setup-dependency.sh b/deployment/setup-dependency.sh
index fcb2d51..f1ca4c2 100755
--- a/deployment/setup-dependency.sh
+++ b/deployment/setup-dependency.sh
@@ -1,30 +1,7 @@
#!/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