diff options
author | Mike Elliott <mike.elliott@amdocs.com> | 2018-04-06 18:32:22 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-04-06 18:32:22 +0000 |
commit | e091209b92f0d5369018ae677525e0bc9ff78ad3 (patch) | |
tree | 46fe32aa97c851a64ed556c0daf9d8cc70f7be56 /kubernetes/portal/docker | |
parent | 2afcb1dc12cb7db9737068966235204059b3ae46 (diff) | |
parent | 1db773e68e50f333369ccde727166805bce2b795 (diff) |
Merge "Removing portal schema from configmap"
Diffstat (limited to 'kubernetes/portal/docker')
-rw-r--r-- | kubernetes/portal/docker/init/mariadb-client/Dockerfile | 37 | ||||
-rw-r--r-- | kubernetes/portal/docker/init/mariadb-client/db_migrate.sh | 23 |
2 files changed, 56 insertions, 4 deletions
diff --git a/kubernetes/portal/docker/init/mariadb-client/Dockerfile b/kubernetes/portal/docker/init/mariadb-client/Dockerfile index 3089bafcfd..009f2fa757 100644 --- a/kubernetes/portal/docker/init/mariadb-client/Dockerfile +++ b/kubernetes/portal/docker/init/mariadb-client/Dockerfile @@ -1,11 +1,40 @@ -FROM ubuntu:16.04 +FROM boxfuse/flyway:5.0.7-alpine +ARG branch=master ENV no_proxy "localhost,127.0.0.1,.cluster.local,$KUBERNETES_SERVICE_HOST" # Setup Corporate proxy ENV https_proxy ${HTTP_PROXY} ENV http_proxy ${HTTPS_PROXY} -RUN apt-get update -RUN apt-get install -y mariadb-client-10.0 +RUN apk add --update \ + mariadb-client=10.1.28-r1 \ + git \ + && rm -rf /var/cache/apk/* -VOLUME /portal-mysql +ENV so_branch=$branch +#ENV policy_branch: $branch +ENV portal_branch=$branch +#ENV sdnc_branch: $branch +#ENV vid_branch: $branch +#ENV clamp_branch: $branch + +#ENV appc_repo: http://gerrit.onap.org/r/appc/deployment.git +ENV so_repo=http://gerrit.onap.org/r/so/docker-config.git +#ENV policy_repo: http://gerrit.onap.org/r/policy/docker.git +ENV portal_repo=http://gerrit.onap.org/r/portal.git +#ENV sdnc_repo: http://gerrit.onap.org/r/sdnc/oam.git +#ENV vid_repo: http://gerrit.onap.org/r/vid.git +#ENV clamp_repo: http://gerrit.onap.org/r/clamp.git + +RUN mkdir -p /onap-sources +WORKDIR /onap-sources + +RUN git clone -b $branch $portal_repo && cd portal && git checkout HEAD +RUN git clone -b $branch $so_repo && cd docker-config && git checkout HEAD + +VOLUME /onap-sources + +COPY db_migrate.sh /root + +RUN chmod a+x /root/db_migrate.sh +ENTRYPOINT /root/db_migrate.sh diff --git a/kubernetes/portal/docker/init/mariadb-client/db_migrate.sh b/kubernetes/portal/docker/init/mariadb-client/db_migrate.sh new file mode 100644 index 0000000000..32a634a9e5 --- /dev/null +++ b/kubernetes/portal/docker/init/mariadb-client/db_migrate.sh @@ -0,0 +1,23 @@ +#!/bin/sh -x +SQL_DEST_DIR=${SQL_DEST_DIR:-/tmp/sql} +DB_PORT=${DB_PORT:-3306} + +[[ -z "$SQL_SRC_DIR" ]] && { echo "Error: SQL_SRC_DIR must be provided as an environment variable"; exit 1; } +[[ -z "$DB_USER" ]] && { echo "Error: DB_USER must be provided as an environment variable"; exit 1; } +[[ -z "$DB_PASS" ]] && { echo "Error: DB_PASS must be provided as an environment variable"; exit 1; } +[[ -z "$DB_HOST" ]] && { echo "Error: DB_HOST must be provided as an environment variable"; exit 1; } + +mkdir -p $SQL_DEST_DIR + +#Find all sql files and copy them to the destination directory +find "/onap-sources/$SQL_SRC_DIR" -type f -iname "*.sql" | awk -v dest="$SQL_DEST_DIR" '{n=split($1,a,"/"); system(sprintf( "cp %s %s", $1, dest"/"a[n])) }' + + +#Not needed right now? +#--database=$DB_NAME + +#--force to deal with duplicate records in absense of "insert ignore" +##ERROR 1062 (23000) at line 382: Duplicate entry '2' for key 'PRIMARY' + +cd $SQL_DEST_DIR +cat *.sql | mysql -vv --user=$DB_USER --password=$DB_PASS --host=$DB_HOST --port=$DB_PORT --force |