Skip to content

Commit a00b460

Browse files
Xavier MetichecchiaXavier Metichecchia
authored andcommitted
Rework environmental variables for database
1 parent 0f2da3b commit a00b460

File tree

4 files changed

+56
-22
lines changed

4 files changed

+56
-22
lines changed

.circleci/config.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,22 @@ jobs:
3535
command: |
3636
sed -i 's@name: analytics-reporter-api@name: analytics-reporter-api-develop@g' manifest.yml
3737
sed -i 's@- analytics-reporter-database@- analytics-reporter-database-develop@g' manifest.yml
38-
cat manifest.yml
3938
- run:
4039
name: Run sed on entrypoint.sh when deploying to develop
4140
command: |
4241
sed -i 's@NEW_RELIC_APP_NAME="analytics-reporter-api"@NEW_RELIC_APP_NAME="analytics-reporter-api-develop"@g' entrypoint.sh
4342
43+
- run:
44+
name: Delete Knewfile.js and drop sufffix on Knexfile.js.cloudgov
45+
command: |
46+
rm knexfile.js
47+
mv knexfile.js.cloudgov knexfile.js
48+
4449
- run:
4550
name: Install CF CLI
4651
command: |
47-
sudo wget --user-agent "Mozilla" -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - && sudo echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list && sudo apt-get update && sudo apt-get -y install cf8-cli curl
52+
sudo curl -v -L -o cf8-cli-installer_8.7.4_x86-64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=8.7.4'
53+
sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
4854
4955
- run:
5056
name: deploy
@@ -53,8 +59,6 @@ jobs:
5359
# Log into cloud.gov
5460
cf api api.fr.cloud.gov
5561
cf login -u $CF_USERNAME_DEV -p $CF_PASSWORD_DEV -o gsa-opp-analytics -s analytics-dev
56-
pwd
57-
ls -l
5862
cat manifest.yml
5963
cf push -f "./manifest.yml"
6064
cf logout

entrypoint.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
#!/bin/sh
2-
#Set Postgres env vars from VCAP_SERVICES
3-
export POSTGRES_DATABASE=$(echo $VCAP_SERVICES | jq -r '."aws-rds"[].credentials.db_name')
4-
export POSTGRES_HOST=$(echo $VCAP_SERVICES | jq -r '."aws-rds"[].credentials.host')
5-
export POSTGRES_PASSWORD=$(echo $VCAP_SERVICES | jq -r '."aws-rds"[].credentials.password')
6-
export POSTGRES_USER=$(echo $VCAP_SERVICES | jq -r '."aws-rds"[].credentials.username')
7-
8-
9-
#This line will get sed replaced based on the environment/branch
1+
#!/bin/bash
102
export NEW_RELIC_APP_NAME="analytics-reporter-api"
113
export NODE_ENV="test"
4+
export PATH="$PATH:/home/vcap/deps/0/bin"
5+
node deploy/cron.js
6+

knexfile.js.cloudgov

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = {
2+
development: {
3+
client: 'postgresql',
4+
connection: {
5+
database: 'analytics-reporter'
6+
}
7+
},
8+
production: {
9+
client: 'postgresql',
10+
connection: {
11+
host : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["host"],
12+
user : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["username"],
13+
password : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["password"],
14+
database : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["db_name"],
15+
16+
},
17+
pool: {
18+
min: 2,
19+
max: 10
20+
},
21+
migrations: {
22+
tableName: 'knex_migrations'
23+
}
24+
},
25+
test: {
26+
client: 'postgresql',
27+
connection: {
28+
user: process.env.CIRCLECI ? 'postgres' : undefined,
29+
database: 'analytics-api-test'
30+
},
31+
migrations: {
32+
tableName: 'knex_migrations'
33+
}
34+
}
35+
};

manifest.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
---
21
applications:
3-
- name: analytics-reporter-api
4-
buildpack: https://github.com/cloudfoundry/nodejs-buildpack
5-
memory: 128M
6-
instances: 2
7-
command: "chmod +x ./entrypoint.sh && ./entrypoint.sh && npm start"
8-
services:
9-
- analytics-reporter-database
10-
stack: cflinuxfs4
2+
- name: analytics-reporter-api
3+
instances: 1
4+
memory: 128M
5+
buildpacks:
6+
- nodejs_buildpack
7+
command: "chmod +x ./entrypoint.sh && ./entrypoint.sh"
8+
services:
9+
- analytics-reporter-database
10+
stack: cflinuxfs4

0 commit comments

Comments
 (0)