From 2ad2d483008c8170709f8176529a66f13639bf6d Mon Sep 17 00:00:00 2001 From: NadunDeSilva Date: Wed, 12 Jun 2019 22:31:45 +0530 Subject: [PATCH] Update IdP setup process to run on a container --- .gitignore | 2 +- Makefile | 4 +-- deployment/docker-compose.yml | 5 ++++ docker/deployment-init/Dockerfile | 30 +++++++++++++++++++ .../files/create-cli-app.xml | 0 .../files/create-github-idp.xml | 2 +- .../files/create-google-idp.xml | 2 +- .../files/create-oauth2-app-cellery-hub.xml | 0 .../files/create-oauth2-app-cli.xml | 0 .../files/create-web-portal-app.xml | 0 docker/deployment-init/files/idp-variables.sh | 12 ++++++++ .../files/setup-is.sh | 18 ++++++++++- .../files/update-cellery-hub-application.xml | 0 .../files/update-cli-application.xml | 0 docker/identity-server/files/idp-variables.sh | 12 -------- 15 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 docker/deployment-init/Dockerfile rename docker/{identity-server => deployment-init}/files/create-cli-app.xml (100%) rename docker/{identity-server => deployment-init}/files/create-github-idp.xml (99%) rename docker/{identity-server => deployment-init}/files/create-google-idp.xml (98%) rename docker/{identity-server => deployment-init}/files/create-oauth2-app-cellery-hub.xml (100%) rename docker/{identity-server => deployment-init}/files/create-oauth2-app-cli.xml (100%) rename docker/{identity-server => deployment-init}/files/create-web-portal-app.xml (100%) create mode 100644 docker/deployment-init/files/idp-variables.sh rename docker/{identity-server => deployment-init}/files/setup-is.sh (89%) rename docker/{identity-server => deployment-init}/files/update-cellery-hub-application.xml (100%) rename docker/{identity-server => deployment-init}/files/update-cli-application.xml (100%) delete mode 100644 docker/identity-server/files/idp-variables.sh diff --git a/.gitignore b/.gitignore index 3225767..a17368c 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,6 @@ hs_err_pid* deployment/mysql/mnt deployment/docker-registry/mnt deployment/docker-auth/extension-logs -docker/identity-server/files/idp-variables.sh +docker/deployment-init/files/idp-variables.sh coverage.txt diff --git a/Makefile b/Makefile index 5f3acb7..8a88af6 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ docker: docker build -t $(DOCKER_REPO)/cellery-hub-api:$(VERSION) -f ./docker/api/Dockerfile . docker build -t $(DOCKER_REPO)/cellery-hub-portal:$(VERSION) -f ./docker/portal/Dockerfile . mvn clean install -f docker/identity-server/pom.xml + docker build -t $(DOCKER_REPO)/cellery-hub-deployment-init:$(VERSION) -f ./docker/deployment-init/Dockerfile . .PHONY: docker-push docker-push: docker @@ -81,6 +82,7 @@ docker-push: docker docker push $(DOCKER_REPO)/cellery-hub-api:$(VERSION) docker push $(DOCKER_REPO)/cellery-hub-portal:$(VERSION) docker push $(DOCKER_REPO)/cellery-hub-idp:$(VERSION) + docker push $(DOCKER_REPO)/cellery-hub-deployment-init:$(VERSION) .PHONY: deploy deploy: @@ -89,8 +91,6 @@ deploy: mkdir -p deployment/docker-auth/extension-logs cd deployment; \ docker-compose up -d - cd docker/identity-server/files; \ - bash setup-is.sh .PHONY: undeploy undeploy: diff --git a/deployment/docker-compose.yml b/deployment/docker-compose.yml index 348234c..e2f79d8 100644 --- a/deployment/docker-compose.yml +++ b/deployment/docker-compose.yml @@ -89,3 +89,8 @@ services: - ./mysql/mnt:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=root + deployment-init: + image: wso2cellery/cellery-hub-deployment-init:latest + restart: "no" + environment: + - CELLERY_HUB_IDP_URL=https://idp.hub.cellery.io:9443 diff --git a/docker/deployment-init/Dockerfile b/docker/deployment-init/Dockerfile new file mode 100644 index 0000000..4470498 --- /dev/null +++ b/docker/deployment-init/Dockerfile @@ -0,0 +1,30 @@ +# ------------------------------------------------------------------------ +# +# Copyright 2019 WSO2, Inc. (http://wso2.com) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License +# +# ------------------------------------------------------------------------ + +FROM ubuntu:bionic +LABEL MAINTAINER="WSO2 Cellery Maintainers " + +COPY ./docker/deployment-init/files/ ./ + +RUN apt-get -y update;\ + apt-get -y upgrade;\ + apt-get -y install curl + +ENV TERM=xterm-256color + +ENTRYPOINT ["bash", "setup-is.sh"] diff --git a/docker/identity-server/files/create-cli-app.xml b/docker/deployment-init/files/create-cli-app.xml similarity index 100% rename from docker/identity-server/files/create-cli-app.xml rename to docker/deployment-init/files/create-cli-app.xml diff --git a/docker/identity-server/files/create-github-idp.xml b/docker/deployment-init/files/create-github-idp.xml similarity index 99% rename from docker/identity-server/files/create-github-idp.xml rename to docker/deployment-init/files/create-github-idp.xml index aadb701..d4062ef 100644 --- a/docker/identity-server/files/create-github-idp.xml +++ b/docker/deployment-init/files/create-github-idp.xml @@ -181,7 +181,7 @@ 0 callbackUrl false - {CELLERY_HUB_FEDERATED_CALLBACL_URL} + {CELLERY_HUB_FEDERATED_CALLBACK_URL} diff --git a/docker/identity-server/files/create-google-idp.xml b/docker/deployment-init/files/create-google-idp.xml similarity index 98% rename from docker/identity-server/files/create-google-idp.xml rename to docker/deployment-init/files/create-google-idp.xml index 75d7b9c..8967df9 100644 --- a/docker/identity-server/files/create-google-idp.xml +++ b/docker/deployment-init/files/create-google-idp.xml @@ -54,7 +54,7 @@ 0 callbackUrl false - {CELLERY_HUB_FEDERATED_CALLBACL_URL} + {CELLERY_HUB_FEDERATED_CALLBACK_URL} diff --git a/docker/identity-server/files/create-oauth2-app-cellery-hub.xml b/docker/deployment-init/files/create-oauth2-app-cellery-hub.xml similarity index 100% rename from docker/identity-server/files/create-oauth2-app-cellery-hub.xml rename to docker/deployment-init/files/create-oauth2-app-cellery-hub.xml diff --git a/docker/identity-server/files/create-oauth2-app-cli.xml b/docker/deployment-init/files/create-oauth2-app-cli.xml similarity index 100% rename from docker/identity-server/files/create-oauth2-app-cli.xml rename to docker/deployment-init/files/create-oauth2-app-cli.xml diff --git a/docker/identity-server/files/create-web-portal-app.xml b/docker/deployment-init/files/create-web-portal-app.xml similarity index 100% rename from docker/identity-server/files/create-web-portal-app.xml rename to docker/deployment-init/files/create-web-portal-app.xml diff --git a/docker/deployment-init/files/idp-variables.sh b/docker/deployment-init/files/idp-variables.sh new file mode 100644 index 0000000..1df4187 --- /dev/null +++ b/docker/deployment-init/files/idp-variables.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +export CELLERY_HUB_IDP_URL=${CELLERY_HUB_IDP_URL:-https://localhost:9443} +export CELLERY_HUB_GOOGLE_CLIENT_ID=${CELLERY_HUB_GOOGLE_CLIENT_ID:-fillMe} +export CELLERY_HUB_GOOGLE_CLIENT_SECRET=${CELLERY_HUB_GOOGLE_CLIENT_SECRET:-fillMe} +export CELLERY_HUB_GITHUB_CLIENT_ID=${CELLERY_HUB_GITHUB_CLIENT_ID:-fillMe} +export CELLERY_HUB_GITHUB_CLIENT_SECRET=${CELLERY_HUB_GITHUB_CLIENT_SECRET:-fillMe} +export CELLERY_HUB_CLI_CALL_BACK_URL=regexp=http://localhost:[0-9]+/\(.*\) +export CELLERY_HUB_WEB_PORTAL_CALLBACK=regexp=https://hub.cellery.io:9000/\(.*\) +export CELLERY_HUB_FEDERATED_CALLBACK_URL=https://idp.hub.cellery.io:9443/commonauth +export CELLERY_HUB_IDP_ADMIN_USERNAME=admin +export CELLERY_HUB_IDP_ADMIN_PASSWORD=admin diff --git a/docker/identity-server/files/setup-is.sh b/docker/deployment-init/files/setup-is.sh similarity index 89% rename from docker/identity-server/files/setup-is.sh rename to docker/deployment-init/files/setup-is.sh index 707c680..3e3e17a 100644 --- a/docker/identity-server/files/setup-is.sh +++ b/docker/deployment-init/files/setup-is.sh @@ -1,8 +1,24 @@ #!/usr/bin/env bash +# ------------------------------------------------------------------------ +# +# Copyright 2019 WSO2, Inc. (http://wso2.com) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License +# +# ------------------------------------------------------------------------ source idp-variables.sh -echo echo "Waiting for IdP to start" while [[ true ]]; do diff --git a/docker/identity-server/files/update-cellery-hub-application.xml b/docker/deployment-init/files/update-cellery-hub-application.xml similarity index 100% rename from docker/identity-server/files/update-cellery-hub-application.xml rename to docker/deployment-init/files/update-cellery-hub-application.xml diff --git a/docker/identity-server/files/update-cli-application.xml b/docker/deployment-init/files/update-cli-application.xml similarity index 100% rename from docker/identity-server/files/update-cli-application.xml rename to docker/deployment-init/files/update-cli-application.xml diff --git a/docker/identity-server/files/idp-variables.sh b/docker/identity-server/files/idp-variables.sh deleted file mode 100644 index 8dbd891..0000000 --- a/docker/identity-server/files/idp-variables.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -export CELLERY_HUB_IDP_URL=${CELLERY_HUB_IDP_URL:-https://localhost:9443} -export CELLERY_HUB_GOOGLE_CLIENT_ID=fillMe -export CELLERY_HUB_GOOGLE_CLIENT_SECRET=fillMe -export CELLERY_HUB_GITHUB_CLIENT_ID=fillMe -export CELLERY_HUB_GITHUB_CLIENT_SECRET=fillMe -export CELLERY_HUB_CLI_CALL_BACK_URL=regexp=http://localhost:[0-9]+/\(.*\) -export CELLERY_HUB_WEB_PORTAL_CALLBACK=regexp=https://hub.cellery.io:9000/\(.*\) -export CELLERY_HUB_FEDERATED_CALLBACL_URL=https://idp.hub.cellery.io:9443/commonauth -export CELLERY_HUB_IDP_ADMIN_USERNAME=admin -export CELLERY_HUB_IDP_ADMIN_PASSWORD=admin