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

Commit 54387d8

Browse files
author
sachin-maheshwari
authored
Merge pull request #1 from topcoder-platform/develop
Shapeup#2 v5 user fortification
2 parents 5fc74de + 13a8f4f commit 54387d8

File tree

6 files changed

+96
-8
lines changed

6 files changed

+96
-8
lines changed

.circleci/config.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
version: 2
2+
defaults: &defaults
3+
docker:
4+
- image: circleci/python:2.7.18-stretch-browsers
5+
install_dependency: &install_dependency
6+
name: Installation of build and deployment dependencies.
7+
command: |
8+
sudo apt install jq
9+
sudo pip install awscli --upgrade
10+
sudo pip install docker-compose
11+
install_deploysuite: &install_deploysuite
12+
name: Installation of install_deploysuite.
13+
command: |
14+
git clone --branch v1.4.3 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
15+
cp ./../buildscript/master_deploy.sh .
16+
cp ./../buildscript/buildenv.sh .
17+
cp ./../buildscript/awsconfiguration.sh .
18+
restore_cache_settings_for_build: &restore_cache_settings_for_build
19+
key: docker-node-modules-{{ checksum "package-lock.json" }}
20+
21+
save_cache_settings: &save_cache_settings
22+
key: docker-node-modules-{{ checksum "package-lock.json" }}
23+
paths:
24+
- node_modules
25+
26+
builddeploy_steps: &builddeploy_steps
27+
- checkout
28+
- setup_remote_docker
29+
- run: *install_dependency
30+
- run: *install_deploysuite
31+
- restore_cache: *restore_cache_settings_for_build
32+
- run: ./build.sh ${APPNAME}
33+
- save_cache: *save_cache_settings
34+
- deploy:
35+
name: Running MasterScript.
36+
command: |
37+
./awsconfiguration.sh $DEPLOY_ENV
38+
source awsenvconf
39+
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar
40+
source buildenvvar
41+
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}
42+
43+
44+
jobs:
45+
# Build & Deploy against development backend
46+
"build-dev":
47+
<<: *defaults
48+
environment:
49+
DEPLOY_ENV: "DEV"
50+
LOGICAL_ENV: "dev"
51+
APPNAME: "u-bahn-backendjob"
52+
steps: *builddeploy_steps
53+
54+
"build-prod":
55+
<<: *defaults
56+
environment:
57+
DEPLOY_ENV: "PROD"
58+
LOGICAL_ENV: "prod"
59+
APPNAME: "u-bahn-backendjob"
60+
steps: *builddeploy_steps
61+
62+
workflows:
63+
version: 2
64+
build:
65+
jobs:
66+
# Development builds are executed on "develop" branch only.
67+
- "build-dev":
68+
context : org-global
69+
filters:
70+
branches:
71+
only:
72+
- develop
73+
74+
# Production builds are exectuted only on tagged commits to the
75+
# master branch.
76+
- "build-prod":
77+
context : org-global
78+
filters:
79+
branches:
80+
only: master

config/default.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module.exports = {
1313

1414
AUTH0_URL: process.env.AUTH0_URL || 'https://topcoder-dev.auth0.com/oauth/token', // Auth0 credentials
1515
AUTH0_AUDIENCE: process.env.AUTH0_TOPCODER_AUDIENCE || 'https://m2m.topcoder-dev.com/',
16-
TOKEN_CACHE_TIME: process.env.TOKEN_CACHE_TIME,
1716
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
1817
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET,
1918
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL,
@@ -24,6 +23,7 @@ module.exports = {
2423
DB_HOST: process.env.DB_HOST || 'localhost',
2524
DB_PORT: process.env.DB_PORT || 5432,
2625

26+
REDIS_URL: process.env.REDIS_URL,
2727
REDIS_HOST: process.env.REDIS_HOST || 'localhost',
2828
REDIS_PORT: parseInt(process.env.REDIS_PORT || 6379),
2929
REDIS_PASSWORD: process.env.REDIS_PASSWORD,

docker/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
FROM node:12.16.3
33

44
# Copy the current directory into the Docker image
5-
COPY . /ubahn-skill-processor-trigger
5+
COPY . /u-bahn-backendjob
66

77
# Set working directory for future use
8-
WORKDIR /ubahn-skill-processor-trigger
8+
WORKDIR /u-bahn-backendjob
99

1010
# Install the dependencies from package.json
1111
RUN npm install

docker/docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3'
22
services:
3-
ubahn-skill-processor-trigger:
4-
image: ubahn-skill-processor-trigger:latest
3+
u-bahn-backendjob:
4+
image: u-bahn-backendjob:latest
55
build:
66
context: ../
77
dockerfile: docker/Dockerfile

src/app.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ const User = sequelize.models.User
1414
/**
1515
* Send user skill event
1616
*/
17-
async function main () {
17+
async function main() {
18+
const redis_url = config.REDIS_URL
1819
let offset = config.USER_RECORD_OFFSET
19-
const client = redis.createClient({ host: config.REDIS_HOST, port: config.REDIS_PORT, password: config.REDIS_PASSWORD, user: config.REDIS_USER })
20+
let client
21+
22+
if (redis_url) {
23+
client = redis.createClient(redis_url)
24+
} else {
25+
client = redis.createClient({ host: config.REDIS_HOST, port: config.REDIS_PORT, password: config.REDIS_PASSWORD, user: config.REDIS_USER })
26+
}
27+
2028
const offsetFromRedis = await promisify(client.get).bind(client)(config.OFFSET_REDIS_KEY)
2129
if (offsetFromRedis) {
2230
offset = offsetFromRedis

src/common/helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const _ = require('lodash')
55
const config = require('config')
66
const logger = require('./logger')
77
const busApi = require('tc-bus-api-wrapper')
8-
const busApiClient = busApi(_.pick(config, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME', 'AUTH0_CLIENT_ID',
8+
const busApiClient = busApi(_.pick(config, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'AUTH0_CLIENT_ID',
99
'AUTH0_CLIENT_SECRET', 'BUSAPI_URL', 'KAFKA_ERROR_TOPIC', 'AUTH0_PROXY_SERVER_URL']))
1010

1111
/**

0 commit comments

Comments
 (0)