Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from SUSE/master
Browse files Browse the repository at this point in the history
merge in msater
  • Loading branch information
Irfan Habib committed Oct 31, 2017
2 parents 0fddd6e + 5bebc96 commit f4c1e4a
Show file tree
Hide file tree
Showing 27 changed files with 303 additions and 160 deletions.
5 changes: 5 additions & 0 deletions deploy/build_portal_proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
set -x

pushd $(git rev-parse --show-toplevel)
BUILD_ARGS=""
if [ ! -z "${BUILD_MIGRATOR}" ]; then
BUILD_ARGS='-e BUILD_DB_MIGRATOR="true"'
fi

docker run -it \
--rm \
-e USER_NAME=$(id -nu) \
-e USER_ID=$(id -u) \
-e GROUP_ID=$(id -g) \
${BUILD_ARGS} \
--name console-proxy-builder \
--volume $(pwd):/go/src/github.com/SUSE/stratos-ui \
splatform/stratos-proxy-builder:opensuse $*
Expand Down
1 change: 0 additions & 1 deletion deploy/ci/tasks/release/create-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ run:
args:
- -exc
- |
# Expect this command to fail since k8s isn't available but it will initialise helm locally
helm init || true
ROOT_DIR=$PWD
Expand Down
8 changes: 7 additions & 1 deletion deploy/ci/tasks/stratos-ui/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@ run:
"password": "${CONSOLE_USER_PASSWORD}"
}
},
"uaa": {
"url": "http://uaa:8080",
"clientId": "console",
"adminUsername": "admin",
"adminPassword": "hscadmin"
},
"githubPat": "${GITHUB_TOKEN}"
}
EOF
cat ../build/secrets.json
for image in splatform/stratos-goose-base:opensuse splatform/stratos-bk-base:opensuse splatform/stratos-nginx-base:opensuse splatform/stratos-uaa splatform/stratos-concourse; do
for image in splatform/stratos-bk-base:opensuse splatform/stratos-nginx-base:opensuse splatform/stratos-uaa splatform/stratos-concourse; do
docker pull ${REGISTRY_NAME}/$image
docker tag ${REGISTRY_NAME}/$image $image
done
Expand Down
10 changes: 6 additions & 4 deletions deploy/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ services:


mariadb:
extends: imageCommon
image: mariadb:latest
extends: buildCommon
build:
context: ../deploy/db
dockerfile: Dockerfile.mariadb
env_file:
./mariadb.env
ports:
Expand All @@ -36,8 +38,8 @@ services:
goose:
extends: buildCommon
build:
context: ../deploy
dockerfile: db/Dockerfile.goose.dev
context: ../
dockerfile: deploy/db/Dockerfile.goose.dev
environment:
- DATABASE_PROVIDER=mysql

Expand Down
7 changes: 5 additions & 2 deletions deploy/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
set -e

rm -rf node_modules
npm install
npm install --production
if [ ! -z ${BUILD_DB_MIGRATOR} ]; then
npm run build-migrator
else
npm run build-backend

fi
if [ "${USER_NAME}" != "root" ]; then
useradd -G users -u ${USER_ID} ${USER_NAME}
chown -R ${USER_NAME}:${GROUP_ID} outputs/
Expand Down
12 changes: 7 additions & 5 deletions deploy/db/Dockerfile.goose.dev
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM splatform/stratos-goose-base:opensuse
FROM splatform/stratos-bk-base:opensuse

WORKDIR /src

COPY db/dbconf.yml db/dbconf.yml
COPY db/migrations db/migrations
COPY db/scripts/development.sh .
COPY db/scripts/wait-for-it.sh .
COPY deploy/db/dbconf.yml db/dbconf.yml
COPY deploy/db/migrations db/migrations
COPY deploy/db/scripts/development.sh .
COPY deploy/db/scripts/wait-for-it.sh .
COPY outputs/stratos-dbmigrator .
RUN chmod +x stratos-dbmigrator
RUN chmod +x wait-for-it.sh
RUN chmod +x development.sh

Expand Down
6 changes: 3 additions & 3 deletions deploy/db/Dockerfile.k8s.postflight-job
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM splatform/stratos-goose-base:opensuse
FROM splatform/stratos-bk-base:opensuse

RUN zypper -n in postgresql mariadb-client
RUN go get github.com/go-sql-driver/mysql
COPY goose /usr/local/bin/
COPY outputs/stratos-dbmigrator /usr/local/bin/
RUN chmod +x /usr/local/bin/stratos-dbmigrator
COPY deploy/db/dbconf.yml db/dbconf.yml
COPY deploy/db/migrations db/migrations
COPY deploy/db/scripts/run-postflight-job.k8s.sh /run-postflight-job.sh
Expand Down
9 changes: 9 additions & 0 deletions deploy/db/Dockerfile.mariadb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM splatform/stratos-db-base:opensuse

COPY mariadb-entrypoint.sh /docker-entrypoint.sh

# ENTRYPOINT
ENTRYPOINT ["/docker-entrypoint.sh"]

EXPOSE 3306
CMD ["mysqld_safe"]
47 changes: 47 additions & 0 deletions deploy/db/mariadb-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
set -e

MYSQL_DATADIR="/var/lib/mysql"

if [ ! -d "$MYSQL_DATADIR/mysql" ]; then
# if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" ]; then
# echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set'
# echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
# exit 1
# fi

echo 'Running mysql_install_db ...'
mysql_install_db --datadir="$MYSQL_DATADIR"
echo 'Finished mysql_install_db'

# These statements _must_ be on individual lines, and _must_ end with
# semicolons (no line breaks or comments are permitted).
# TODO proper SQL escaping on ALL the things D:

tempSqlFile='/tmp/mysql-first-time.sql'
cat > "$tempSqlFile" <<-EOSQL
DELETE FROM mysql.user ;
CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
DROP DATABASE IF EXISTS test ;
EOSQL

if [ "$MYSQL_DATABASE" ]; then
echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" >> "$tempSqlFile"
fi

if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then
echo "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;" >> "$tempSqlFile"

if [ "$MYSQL_DATABASE" ]; then
echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* TO '$MYSQL_USER'@'%' ;" >> "$tempSqlFile"
fi
fi

echo 'FLUSH PRIVILEGES ;' >> "$tempSqlFile"
set -- "$@" --init-file="$tempSqlFile"
fi

chown -R mysql:mysql "$MYSQL_DATADIR"

exec "$@"
12 changes: 6 additions & 6 deletions deploy/db/scripts/development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ set -e

# Check the version
echo "Checking database version."
$GOPATH/bin/goose --env=mariadb-development dbversion
./stratos-dbmigrator --env=mariadb-development dbversion

EXITVAL=$?
while [ $EXITVAL -ne 0 ]
do
echo "Failed to execute dbversion check, retrying after one second"
sleep 1
$GOPATH/bin/goose --env=mariadb-development dbversion
./stratos-dbmigrator --env=mariadb-development dbversion
EXITVAL=$?
done

# Check the status
echo "Checking database status."
$GOPATH/bin/goose --env=mariadb-development status
./stratos-dbmigrator --env=mariadb-development status

# Run migrations
echo "Attempting database migrations."
$GOPATH/bin/goose --env=mariadb-development up
./stratos-dbmigrator --env=mariadb-development up

# CHeck the status
echo "Checking database status."
$GOPATH/bin/goose --env=mariadb-development status
./stratos-dbmigrator --env=mariadb-development status

# Check the version
echo "Checking database version."
$GOPATH/bin/goose --env=mariadb-development dbversion
./stratos-dbmigrator --env=mariadb-development dbversion

echo "Database operation(s) complete."

Expand Down
14 changes: 7 additions & 7 deletions deploy/db/scripts/run-postflight-job.k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function execStatement {
stmt=$1

if [ "$DATABASE_PROVIDER" = "mysql" ]; then
echo "Executing: mysql -u $DB_ADMIN_USER -h $DB_HOST -P $DB_PORT -p$DB_ADMIN_PASSWORD -e $stmt"
echo "Executing: mysql -u $DB_ADMIN_USER -h $DB_HOST -P $DB_PORT -p****** -e $stmt"
mysql -u $DB_ADMIN_USER -h $DB_HOST -P $DB_PORT -p$DB_ADMIN_PASSWORD -e $stmt
fi

Expand Down Expand Up @@ -54,26 +54,26 @@ fi
echo "Checking database to see if migration is necessary."

echo "DBCONFIG: $DBCONF_KEY"
echo "Connection string: $DB_USER:$DB_PASSWORD@tcp($DB_HOST:$DB_PORT)/$DB_DATABASE_NAME?parseTime=true"
echo "Connection string: $DB_USER:********@tcp($DB_HOST:$DB_PORT)/$DB_DATABASE_NAME?parseTime=true"
# Check the version
echo "Checking database version."
goose --env=$DBCONF_KEY dbversion
stratos-dbmigrator --env=$DBCONF_KEY dbversion

# Check the status
echo "Checking database status."
goose --env=$DBCONF_KEY status
stratos-dbmigrator --env=$DBCONF_KEY status

# Run migrations
echo "Attempting database migrations."
goose --env=$DBCONF_KEY up
stratos-dbmigrator --env=$DBCONF_KEY up

# CHeck the status
echo "Checking database status."
goose --env=$DBCONF_KEY status
stratos-dbmigrator --env=$DBCONF_KEY status

# Check the version
echo "Checking database version."
goose --env=$DBCONF_KEY dbversion
stratos-dbmigrator --env=$DBCONF_KEY dbversion

echo "Database operation(s) complete."

Expand Down
3 changes: 0 additions & 3 deletions deploy/docker-compose/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ function cleanup {
echo "-- Cleaning up ${STRATOS_UI_PATH}/deploy/containers/nginx/dist"
rm -rf ${STRATOS_UI_PATH}/deploy/containers/nginx/dist

rm -f ${STRATOS_UI_PATH}/goose

}

function updateTagForRelease {
Expand Down Expand Up @@ -192,7 +190,6 @@ function buildGoose {
# Build the postflight container
echo
echo "-- Build & publish the runtime container image for the postflight job"
preloadImage splatform/stratos-goose-base:opensuse
buildAndPublishImage stratos-dc-goose ./db/Dockerfile.goose.dev ${STRATOS_UI_PATH}/deploy
rm -f ${STRATOS_UI_PATH}/goose
}
Expand Down
5 changes: 0 additions & 5 deletions deploy/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ Open a terminal and cd to the `deploy/kubernetes` directory:
$ cd deploy/kubernetes
```

Fetch dependant helm charts
```
$ helm dep build
```

Run helm install:

```
Expand Down
26 changes: 18 additions & 8 deletions deploy/kubernetes/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ function cleanup {
echo "-- Cleaning up ${STRATOS_UI_PATH}/deploy/containers/nginx/dist"
rm -rf ${STRATOS_UI_PATH}/deploy/containers/nginx/dist

rm -f ${STRATOS_UI_PATH}/goose

}

function preloadImage {
Expand Down Expand Up @@ -249,17 +247,28 @@ function buildPostflightJob {
# Build the postflight container
echo
echo "-- Build & publish the runtime container image for the postflight job"

pushd ${STRATOS_UI_PATH} > /dev/null 2>&1
docker run \
${RUN_ARGS} \
-it \
--rm \
--name postflight-builder \
--volume $(pwd):/go/bin/ \
${DOCKER_REGISTRY}/${DOCKER_ORG}/stratos-postflight-builder:${BASE_IMAGE_TAG}
mv goose ${STRATOS_UI_PATH}/
-e USER_NAME=$(id -nu) \
-e USER_ID=$(id -u) \
-e GROUP_ID=$(id -g) \
-e BUILD_DB_MIGRATOR="true" \
--name stratos-proxy-builder \
--volume $(pwd):/go/src/github.com/SUSE/stratos-ui \
${DOCKER_REGISTRY}/${DOCKER_ORG}/stratos-proxy-builder:${BASE_IMAGE_TAG}
buildAndPublishImage stratos-postflight-job deploy/db/Dockerfile.k8s.postflight-job ${STRATOS_UI_PATH}
rm -f ${STRATOS_UI_PATH}/goose
popd > /dev/null 2>&1

}

function buildMariaDb {
echo
echo "-- Building/publishing MariaDB"
# Download and retag image to save bandwidth
buildAndPublishImage stratos-mariadb Dockerfile.mariadb ${STRATOS_UI_PATH}/deploy/db
}

function buildUI {
Expand Down Expand Up @@ -305,6 +314,7 @@ updateTagForRelease
buildProxy
buildPreflightJob
buildPostflightJob
buildMariaDb
buildUI

if [ ${CONCOURSE_BUILD:-"not-set"} == "not-set" ]; then
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/console/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
description: A Helm chart for deploying Console
description: A Helm chart for deploying Stratos UI Console
name: console
version: 0.1.0
6 changes: 0 additions & 6 deletions deploy/kubernetes/console/requirements.lock

This file was deleted.

4 changes: 0 additions & 4 deletions deploy/kubernetes/console/requirements.yaml

This file was deleted.

Loading

0 comments on commit f4c1e4a

Please sign in to comment.