Skip to content

Commit

Permalink
update scores:
Browse files Browse the repository at this point in the history
- gitignore - remove cfee bash
- update app-template
- update scoresMain emoji
- add deployment scripts to cfee
  • Loading branch information
thomassuedbroecker committed May 10, 2019
1 parent 6174923 commit 6d9ddaa
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ scores/webapp/client/src/App.vue
scores/webapp/client/src/components/scoreMain.vue
scores/webapp/deploy_apps/*.log
scores/scores.local.root.env
scores/webapp/deploy_apps/ibmcloud-deploy-webapp-to-cfee.sh
#scores/webapp/deploy_apps/ibmcloud-deploy-webapp-to-cfee.sh
scores/webapp/server/config/manifest.yml

# icp-k8s harald
Expand Down
26 changes: 22 additions & 4 deletions scores/webapp/client/src/App-template.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,39 @@
</b-container>

<!-- Footer -->
<b-container>
<b-container>
<div style="margin-top:20px;"></div>
<browserVerification></browserVerification>
<router-view/>
<b-row>
<b-col style="text-align:center">
<div style="margin-top:50px;margin-bottom:10px;font-size: smaller;color: darkgray;">Brought to you by the <a target="_blank" style="color:#053c9f" href="https://developer.ibm.com/cities/berlin-de/">IBM Developer Advocacy DACH</a> team</div>
<div style="margin-top:10px;margin-bottom:10px;font-size: smaller;color: darkgray;">Read more about the code pattern <a target="_blank" style="color:#053c9f" href="https://developer.ibm.com/patterns/cloud-showcase-blue-mirror/">Mirror game app showcases 15 cloud technologies and components</a></div>
<div style="margin-top:10px;margin-bottom:10px;font-size: smaller;color: darkgray;">Get a free <a target="_blank" style="color:#053c9f" href="https://ibm.biz/nheidloff">IBM Cloud</a> account. Get the <a target="_blank" style="color:#053c9f" href="https://github.com/ibm/blue-cloud-mirror">code</a></div>
</b-col>
</b-row>
<b-row>
<b-col style="text-align:center">
<div style="margin-top:50px">
<div style="margin-top:50px;margin-bottom:10px;font-size: smaller;color: darkgray;"><b>GDPR Consent for the processing of Personal Data within BlueCloudMirror Showcase:</b>
<br>
Data protection and privacy are important to us, which is why we want to ensure transparency. Your consent to play the IBM BlueCloudMirror game is absolutely freely and voluntarily.
<br>
The input of name and e-mail address is voluntary and will not be used in this showcase for any kind of data processing. The photos taken by the player, an essential part of the showcase scenario, are stored and processed only temporarily and locally (within the browser). A transfer via the network (e.g. to an cloud) does not take place.
<br>
If you decide that you want your name to appear on the highscore table: The input of name and e-mail address is voluntary and will only be used to create the high score. A further storage and data processing of these data does not take place either. If you just want to have fun and don't want to provide any personal data play anonymously.
If you decide to participate in the competition (not offered always): The input of name and e-mail address is voluntary as well and will be used to create the high score table (see statement above) and to participate in the raffle of the prize. A further storage and processing of these data does not occur.
<br>
<br>
</div>
<div style="margin-top:10px;margin-bottom:10px;font-size: smaller;color: darkgray;">
</div>
</b-col>
</b-row>
<b-row>
<b-col style="text-align:center">

<div style="margin-top:10px"></div>
<a target="_blank" style="color:#053c9f" href="https://www.ibm.com/privacy/us/en/">IBM Privacy Statement</a> and <a target="_blank" style="color:#053c9f" href="https://www.ibm.com/legal/us/en/">Terms of Use</a></div>
<a target="_blank" style="color:#053c9f" href="https://www.ibm.com/privacy/us/en/">IBM Privacy Statement</a> and <a target="_blank" style="color:#053c9f" href="https://www.ibm.com/legal/us/en/">Terms of Use</a>

<div style="margin-top:10px;margin-bottom:10px;font-size: smaller;color: darkgray;"><a target="_blank" style="color:#053c9f" href="https://www.ibm.com/legal">Imprint / Impressum</a></div>
</b-col>
</b-row>
Expand Down
12 changes: 8 additions & 4 deletions scores/webapp/client/src/components/scoreMain-template.vue
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,11 @@ export default {
}
if (i == 0) {
image = '<img class="responsive" width="35" height="35" src="winner.png"/>';
// image = '<img class="responsive" width="35" height="35" src="winner.png"/>';
image = '<span>&#127942;</span>';
} else {
image = '<img class="responsive" width="30" height="30" src="great.png"/>';
// image = '<img class="responsive" width="30" height="30" src="great.png"/>';
image = '<span>&#127941;</span>';
};
list.push({
Expand All @@ -240,7 +242,8 @@ export default {
} else {
if (returnlist[i].score == lasthighscore) {
ranking = highscorerange;
image = '<img class="responsive" width="30" height="30" src="great.png"/>';
// image = '<img class="responsive" width="30" height="30" src="great.png"/>';
image = '<span>&#127942;</span>';
list.push({
ranking: ranking,
id: returnlist[i]._id,
Expand All @@ -255,7 +258,8 @@ export default {
});
} else {
ranking = ranking + 1;
image = '<img class="responsive" width="30" height="30" src="sleep.png"/>';
//image = '<img class="responsive" width="30" height="30" src="sleep.png"/>';
image = '<span>&#128564</span>';
list.push({
ranking: ranking,
id: returnlist[i]._id,
Expand Down
166 changes: 166 additions & 0 deletions scores/webapp/deploy_apps/ibmcloud-deploy-webapp-to-cfee.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
#!/bin/bash

#!/bin/bash

# Build Webapp
SOURCE="dist"
DESTINATION="/scores/webapp/server"
CLIENT_DEVELOPMENT_DIR="/scores/webapp/client"
SERVER_DEVELOPMENT_DIR="/scores/webapp/server"
SERVER_DEPLOY_DIR="scores/webapp/server/deploy_apps"

#SET ACTUAL PATH
CURRENT_FOLDER=$(cd $(dirname $0); pwd)
cd "../../.."
ROOT_FOLDER=$(cd $(dirname $0); pwd)
cd $CURRENT_FOLDER

# SETUP logging (redirect stdout and stderr to a log file)
readonly LOG_FILE="${CURRENT_FOLDER}/ibmcloud-deploy-webapp-to-cfee.log"
readonly ENV_ROOT_FILE="${ROOT_FOLDER}/scores/scores.local.root.env"
ENV_SERVER_FILE="${ROOT_FOLDER}/scores/webapp/server/.env"
source $ENV_ROOT_FILE
touch $ENV_SERVER_FILE

touch $LOG_FILE
exec 3>&1 # Save stdout
exec 4>&2 # Save stderr
exec 1>$LOG_FILE 2>&1

function _out() {
echo "$@" >&3
echo "$(date +'%F %H:%M:%S') $@"
}

function _err() {
echo "$@" >&4
echo "$(date +'%F %H:%M:%S') $@"
}

function ibmcloud_login_and_set_cfee_env() {
# Skip version check updates
ibmcloud config --check-version=false

# Login to Cloud
_out 1. Login to IBM Cloud
_out

_out _set USER: $IBMCLOUD_USER_ID REGION: $IBMCLOUD_CFEE_CONTAINER_REGION
ibmcloud login -u $IBMCLOUD_USER_ID -apikey $IBMCLOUD_CLI_DEVOPS_PLATFORM_KEY -r $IBMCLOUD_CFEE_CONTAINER_REGION

#ibmcloud cs region-set $IBMCLOUD_CFEE_CONTAINER_REGION
_out _set CFEE-API: $IBMCLOUD_CFEE_API_ENDPOINT CFEE-ORG: $IBMCLOUD_CFEE_ORGANIZATION CFEE-SPACE: $IBMCLOUD_CEFF_SPACE
ibmcloud target --cf-api $IBMCLOUD_CFEE_API_ENDPOINT -o $IBMCLOUD_CFEE_ORGANIZATION -s $IBMCLOUD_CEFF_SPACE

# Show the result of login to stdout
ibmcloud target
_out

_out Login end
_out
}

function setEnv(){
_out
_out 2. SetEnv
_out
# set env
printf "\n# CF APP" >> $ENV_SERVER_FILE
printf "\nSERVICE_USER=$IBMCLOUD_CF_APP_WEB_APP_USER" >> $ENV_SERVER_FILE
printf "\nSERVICE_PASSWORD=$IBMCLOUD_CF_APP_WEB_APP_PASSWORD" >> $ENV_SERVER_FILE
}

function prepareVUEClientCode() {
_out
_out 3. prepare VUE client code start
_out
cd $ROOT_FOLDER/scores/webapp/client/src

_out _copy App.vue template definition
rm "App.vue"
cp "App-template.vue" "App.vue"

cd $ROOT_FOLDER/scores/webapp/client/src/components
_out _copy scoreMain.vue template definition
rm "scoreMain.vue"
cp "scoreMain-template.vue" "scoreMain.vue"

_out _setup text-replace
cd $ROOT_FOLDER/scores/webapp/text-replace
npm install
cd ..
_out _replace $IBMCLOUD_CF_APP_WEBAPP_REPLACE_GAME_URL with $IBMCLOUD_CF_APP_WEBAPP_GAME_URL
npm --prefix "${ROOT_FOLDER}/scores/webapp/text-replace" start "${ROOT_FOLDER}/scores/webapp/client/src/App.vue" $IBMCLOUD_CF_APP_WEBAPP_REPLACE_GAME_URL "$IBMCLOUD_CF_APP_WEBAPP_GAME_URL"
_out _replace $IBMCLOUD_CF_APP_WEBAPP_REPLACE_FUNCTIONS_API_URL with $IBMCLOUD_CF_APP_WEBAPP_FUNCTIONS_API_URL
npm --prefix "${ROOT_FOLDER}/scores/webapp/text-replace" start "${ROOT_FOLDER}/scores/webapp/client/src/components/scoreMain.vue" $IBMCLOUD_CF_APP_WEBAPP_REPLACE_FUNCTIONS_API_URL $IBMCLOUD_CF_APP_WEBAPP_FUNCTIONS_API_URL

_out
_out Prepare VUE client code end
_out
}

function createClient() {
_out
_out 4. Create Client start
_out
cd "${ROOT_FOLDER}${CLIENT_DEVELOPMENT_DIR}"
pwd
rm -rf $IBMCLOUD_CF_APP_WEBAPP_SOURCE

_out _npm install
npm install

_out _build Vue application "${ROOT_FOLDER}${IBMCLOUD_CF_APP_WEBAPP_CLIENT_DEVELOPMENT_DIR}"
npm run build

_out _copy VUE webapp to folder "${ROOT_FOLDER}${IBMCLOUD_CF_APP_WEBAPP_DESTINATION}"
cp -R -f $IBMCLOUD_CF_APP_WEBAPP_SOURCE $ROOT_FOLDER$IBMCLOUD_CF_APP_WEBAPP_DESTINATION

_out
_out Create client end
_out
}

function deployClientToServer() {
_out
_out 5. Deploy to CF start
_out
_out _path "${ROOT_FOLDER}${IBMCLOUD_CF_APP_WEBAPP_SERVER_DEVELOPMENT_DIR}"
cd "$ROOT_FOLDER$IBMCLOUD_CF_APP_WEBAPP_SERVER_DEVELOPMENT_DIR"

_out _deploying Vue application to Cloud Foundry App "${IBMCLOUD_CF_APP_WEBAPP_NAME}"
cd "$ROOT_FOLDER$IBMCLOUD_CF_APP_WEBAPP_SERVER_DEVELOPMENT_DIR"
pwd

_out _npm install
npm install

_out _show existing spaces
ibmcloud cf spaces

_out _show existing apps
ibmcloud cf apps

_out _push PUSH APP TO CF ENTERPRISE ENVIRONMENT
pwd
ibmcloud cf push -f $IBMCLOUD_CFEE_WEBAPP_MANIFEST

HIGHSCORE_CLOUD_FOUNDRY=$(ibmcloud cf r | awk '/$IBMCLOUD_CF_APP_WEBAPP_NAME*/' | awk '{print $2}')
_out _application has been deployed "${HIGHSCORE_CLOUD_FOUNDRY}"
_out Deploy to CF end
_out
}

function endMessage() {
_out
_out "Now please verify the setup in IBM Cloud and for details use the logfile"
_out
}

# Main tasks
ibmcloud_login_and_set_cfee_env
setEnv
prepareVUEClientCode
createClient
deployClientToServer
endMessage

0 comments on commit 6d9ddaa

Please sign in to comment.