Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 6ab5df8

Browse files
author
liuliquan
committed
tc deploy
1 parent 31af668 commit 6ab5df8

File tree

8 files changed

+183
-11
lines changed

8 files changed

+183
-11
lines changed

Gruntfile.js

+2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ module.exports = function (grunt) {
144144
{ match : 'KEYBOARD_SHORTCUT', replacement: process.env.KEYBOARD_SHORTCUT },
145145
{ match : 'CHAT_ICON_DISAPPEAR_TIME', replacement: process.env.CHAT_ICON_DISAPPEAR_TIME },
146146
{ match : 'TC_HOSTNAME', replacement: process.env.TC_HOSTNAME },
147+
{ match : 'TC_AUTH_URL', replacement: process.env.TC_AUTH_URL },
147148
{ match : 'MAX_LIVE_LEADERBOARD', replacement: process.env.MAX_LIVE_LEADERBOARD },
148149
{ match : 'AUTO_SAVING_CODE_INTERVAL', replacement: process.env.AUTO_SAVING_CODE_INTERVAL },
149150
{ match : 'LEADERBOARD_REFRESH_TIME_GAP', replacement: process.env.LEADERBOARD_REFRESH_TIME_GAP },
@@ -158,6 +159,7 @@ module.exports = function (grunt) {
158159
options: {
159160
patterns: [
160161
{ match : 'STATIC_FILE_HOST', replacement: process.env.STATIC_FILE_HOST },
162+
{ match : 'TC_AUTH_URL', replacement: process.env.TC_AUTH_URL },
161163
{ match : 'GOOGLE_ANALYTICS_TRACKING_ID', replacement: process.env.GOOGLE_ANALYTICS_TRACKING_ID },
162164
{ match : 'SPONSOR_URL', replacement: process.env.SPONSOR_URL }
163165
]

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ npm start
8080
1. Start arena services:
8181

8282
- Clone https://github.com/appirio-tech/arena-vm
83-
- Checkout **`dev-local`** branch
84-
- Follow its **`docs/Docker.md`** to start arena services
83+
- Checkout **`dev-master`** branch
84+
- Follow its **`docs/local-deploy.md`** to start arena services
8585

8686
2. Start arena web:
8787

app/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700|Source+Code+Pro:400,600,700' rel='stylesheet' type='text/css' />
1919
<script language="javascript">
2020
if(document.cookie.indexOf("tcsso") == -1) {
21-
document.location = "https://www.topcoder.com/login/?next=https:%2F%2Farena.topcoder.com%2Findex.html";
21+
document.location = "@@TC_AUTH_URL/?retUrl=" + encodeURIComponent("@@STATIC_FILE_HOST/index.html");
2222
}
2323

2424
// global arena object
@@ -51,7 +51,7 @@
5151
<script>
5252
function prepareFrame() {
5353
var ifrm = document.createElement("iframe");
54-
ifrm.setAttribute("src", "https://accounts-auth0.topcoder-dev.com");
54+
ifrm.setAttribute("src", "@@TC_AUTH_URL");
5555
ifrm.style.width = "0px";
5656
ifrm.style.height = "0px";
5757
document.body.appendChild(ifrm);

app/js/app.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1287,8 +1287,7 @@ main.run(['$rootScope', '$state', 'sessionHelper', 'socket', '$window', 'tcTimeS
12871287
if (sessionHelper.getTcsso()) {
12881288
$state.go(helper.STATE_NAME.LoggingIn);
12891289
} else {
1290-
var tchost = config.tcHostName || 'https://www.topcoder.com';
1291-
window.location.href = tchost + "/login?next=" + encodeURIComponent(window.location.href);
1290+
window.location.href = config.tcAuthUrl + "/?retUrl=" + + encodeURIComponent(config.staticFileHost + "/index.html");
12921291
}
12931292
}
12941293
// Move user to deep link, if stored

app/js/config.def.js

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module.exports = {
4646
keyboardShortcut: '@@KEYBOARD_SHORTCUT',
4747
chatIconDisappearTime: '@@CHAT_ICON_DISAPPEAR_TIME',
4848
tcHostName: '@@TC_HOSTNAME',
49+
tcAuthUrl: '@@TC_AUTH_URL',
4950
maxLiveLearderBoard: '@@MAX_LIVE_LEADERBOARD',
5051
autoSavingCodeInterval: '@@AUTO_SAVING_CODE_INTERVAL',
5152
leaderboardRefreshTimeGap: '@@LEADERBOARD_REFRESH_TIME_GAP',

app/js/resolvers.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ resolvers.finishLogin = ['$rootScope', '$q', '$state', '$filter', 'cookies', 'se
144144
// defer the logout promise
145145
deferred = $q.defer();
146146
deferred.promise.then(function () {
147-
var tchost = config.tcHostName || 'https://www.topcoder.com';
148-
window.location.href = tchost + "/login?next=" + encodeURIComponent(window.location.href);
147+
window.location.href = config.tcAuthUrl + "/?retUrl=" + + encodeURIComponent(config.staticFileHost + "/index.html");
149148
});
150149
deferred.resolve();
151150
return deferred.promise;
@@ -1212,9 +1211,8 @@ resolvers.logout = ['$rootScope', '$q', '$state', 'sessionHelper', 'socket', 'ap
12121211
// defer the logout promise
12131212
var deferred = $q.defer();
12141213
deferred.promise.then(function () {
1215-
document.location = "https://www.topcoder.com/logout";
1216-
//var tchost = config.tcHostName || 'https://www.topcoder.com';
1217-
//window.location.href = tchost + "/login?next=" + encodeURIComponent(window.location.href);
1214+
var tchost = config.tcHostName || 'https://www.topcoder.com';
1215+
document.location = tchost + "/logout";
12181216
});
12191217
deferred.resolve();
12201218
return deferred.promise;

arena-web-deploy.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Arena-web TC Deploy
2+
3+
### Prerequisites
4+
5+
- Node 10
6+
7+
### Config
8+
9+
Config env are definied in `config/tc-dev`, pay attention to following values:
10+
11+
| Env Variable | Description | Dev deploy | Prod deploy |
12+
| ---------------- | ------------------------------------------------------------ | --------------------------------------- | ----------------------------------- |
13+
| STATIC_FILE_HOST | This is url where the arena-web exposed to external. | https://arena.topcoder-dev.com | https://arena.topcoder.com |
14+
| TC_AUTH_URL | TC auth url | https://accounts-auth0.topcoder-dev.com | https://accounts-auth0.topcoder.com |
15+
| WEB_SOCKET_URL | Arena WebSocket url. This should map to 5016 port of arena-app docker, e.g by using load balancer. | https://arenaws.topcoder-dev.com | https://arenaws.topcoder.com |
16+
| API_DOMAIN | Endpoint to TC api service. | https://api.topcoder-dev.com/v2 | https://api.topcoder.com/v2 |
17+
| TC_HOSTNAME | TC host | https://www.topcoder-dev.com | https://www.topcoder.com |
18+
19+
### Build
20+
21+
```bash
22+
# Install dependencies
23+
npm install -g bower
24+
npm install -g grunt-cli
25+
npm install
26+
27+
# Build
28+
source config/tc-dev.sh
29+
grunt
30+
31+
# Generate build.zip
32+
grunt deploy-compress
33+
```
34+
35+
### Start
36+
37+
You can either use `npm start` to start a http server at 3000 port, then use load balancer to map to that port;
38+
39+
Or simply upload the `build.zip` to CDN.

config/tc-dev.sh

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#!/bin/bash
2+
3+
# Set environment variables that will be used by grunt.
4+
# The idea here is to still conform to 12factor.net/config even though this is
5+
# a client side app and environment variables are not accessible. These
6+
# values will be copied by grunt into the config.js
7+
8+
# For prod deploy, change to 'NODE_ENV=production'
9+
export NODE_ENV=development
10+
11+
# the HTTP server port
12+
export PORT=3000
13+
14+
# The url where arena-web is exposed to external
15+
export STATIC_FILE_HOST="https://arena.topcoder-dev.com"
16+
17+
# The tc auth host url
18+
export TC_AUTH_URL="https://accounts-auth0.topcoder-dev.com"
19+
20+
# Web socket server url
21+
# This url should map to 5016 port of arena-app service, e.g by using load balancer.
22+
export WEB_SOCKET_URL="https://arenaws.topcoder-dev.com"
23+
24+
# TC-api url
25+
export API_DOMAIN="https://api.topcoder-dev.com/v2"
26+
27+
# The TopCoder host name
28+
export TC_HOSTNAME="https://www.topcoder-dev.com"
29+
30+
31+
export AUTH0_CONNECTION=vm-ldap-connection
32+
export AUTH0_DOMAIN=sma.auth0.com
33+
export AUTH0_CLIENT_ID=CMaBuwSnY0Vu68PLrWatvvu3iIiGPh7t
34+
export CALLBACK_URL=https://www.topcoder-dev.com/reg2/callback.action
35+
36+
export REGISTRATION_URL='https://www.topcoder-dev.com/?action=callback&regSource=arena'
37+
export PW_RESET_URL='https://www.topcoder-dev.com/password-recovery/'
38+
39+
# the cookie key of sso token
40+
export SSO_KEY=tcsso
41+
42+
export AWS_ACCESS_KEY_ID=
43+
export AWS_ACCESS_KEY=
44+
export AWS_BUCKET=
45+
export AWS_FOLDER='arena/md/web-v<%= pkg.version %>/'
46+
47+
export GOOGLE_ANALYTICS_TRACKING_ID=
48+
49+
# the connection timeout to web socket
50+
export CONNECTION_TIMEOUT=30000
51+
52+
# the member photo host
53+
export MEMBER_PHOTO_HOST=http://apps.topcoder.com
54+
55+
export JWT_TOKEN=tcjwt
56+
export CHAT_LENGTH=400
57+
export LOCAL_STORAGE_EXPIRE_TIME=1800
58+
59+
# Facebook API client ID
60+
export FACEBOOK_API_ID=652496988181876
61+
62+
# Message template to post contestant status to Facebook and Twitter
63+
export SOCIAL_STATUS_TEMPLATE='I have participated in __MATCHES__ in #topcoder arena. My current rating is __RATING__.'
64+
# The url of the Web Arena used in posting to Facebook and Twitter
65+
export SOCIAL_ARENA_URL=https://arena.topcoder.com
66+
# The Web Arena description used in posting to Facebook wall
67+
export SOCIAL_ARENA_DESCRIPTION='Algorithm matches for big brains. Solve these and bragging rights are yours.'
68+
# The Web Arena Title used in posting to Facebook wall
69+
export SOCIAL_ARENA_TITLE='TopCoder Arena'
70+
71+
# Message template to post contestant SRM results to Facebook and Twitter
72+
export SOCIAL_SRM_RESULTS_STATUS_TEMPLATE='I was #__POSITION__ with __POINTS__ in the __SRM__NAME__ at the #topcoder Arena'
73+
# The SRM results title used in posting to Facebook wall
74+
export SOCIAL_SRM_RESULTS_STATUS_TITLE='__HANDLE__ shared his SRM results!'
75+
# The SRM results caption used in posting to Facebook wall
76+
export SOCIAL_SRM_RESULTS_STATUS_CAPTION='Join topcoder now!'
77+
# The SRM results picture url used in posting to Facebook wall
78+
export SOCIAL_SRM_RESULTS_STATUS_PICTURE_URL='https://dl.dropboxusercontent.com/u/14772132/arena-picture.png'
79+
80+
export TWEET_TEXT='I am about to participate in a #topcoder arena match, and I am challenging you! To register for the match click arena.topcoder.com.'
81+
export TWEET_URL=arena.topcoder.com
82+
export FACEBOOK_LINK=arena.topcoder.com
83+
84+
export DIVISION_LEADERBOARD_LIMIT=14
85+
86+
# The number of top coders shown in Match Summary widget
87+
export SUMMARY_TOPCODER_COUNT=4
88+
89+
export PRACTICE_PROBLEM_LIST_PAGE_SIZE=10
90+
91+
# The time (in ms) after which the loading spinner times out if there is no activity.
92+
export SPINNER_TIMEOUT=90000
93+
94+
# Google Docs Spreadsheet URL for saving feedbacks and its maxlength
95+
export FEEDBACK_SPREADSHEET_URL=https://script.google.com/macros/s/AKfycbxSDbXXaz5y1wDKWa_XToU2yyi0yAvAobXh8vF2WuT3VrFd14YN/exec
96+
export FEEDBACK_MAXLENGTH=10000
97+
98+
# shortcut configuration
99+
export KEYBOARD_SHORTCUT='shift+tab'
100+
101+
# The time (in ms) to hide the entering / leaving icons in chat area
102+
export CHAT_ICON_DISAPPEAR_TIME=3000
103+
104+
# Time interval between challenge changes in challenge advertising widget (milliseconds)
105+
export CHALLENGE_ADVERTISING_INTERVAL=5000
106+
107+
# The time interval between updates of challenge advertising data from TC-API server (in ms)
108+
export CHALLENGE_ADVERTISING_UPDATE=300000
109+
110+
# The time interval between updates of leaderboard summay (in ms)
111+
export LEADERBOARD_REFRESH_TIME_GAP=1000
112+
113+
# The max live leaderboard number
114+
export MAX_LIVE_LEADERBOARD=200
115+
116+
#The New Relic Browser KEY
117+
export NEWRELIC_BROWSER_APPLICATIONID='4447207'
118+
export NEWRELIC_BROWSER_LICENSCEKEY='28fb2fc79c'
119+
#The New Relic Server KEY
120+
export NEWRELIC_SERVER_APPNAME='testserver'
121+
export NEWRELIC_SERVER_LICENSE_KEY='8f1eb71c599e28fb2b02e7e521488cbabb97174f'
122+
export NEWRELIC_SERVER_LOGGING_LEVEL='trace'
123+
124+
# Time interval for auto saving code (milliseconds)
125+
export AUTO_SAVING_CODE_INTERVAL=30000
126+
127+
# The number of top coders shown in Active Matches Summary widget
128+
export ACTIVE_MATCHES_SUMMARY_TOPCODER_COUNT=3
129+
130+
# The file name of the sponsor logo images. The files must be at app/img/{theme}/
131+
export SPONSOR_LOGO=../img/dark/company_logo.png
132+
export SPONSOR_LOGO_SMALL=../img/dark/company_logo_small.png
133+
export SPONSOR_URL=http://www.appirio.com

0 commit comments

Comments
 (0)