Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(KUI-1323): cleanup local env setup #381

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .azure/prod.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"APPLICATIONINSIGHTS_CONNECTION_STRING",
"KURSPLAN_API_KEY",
"KURSPLAN_API_URI",
"KURS_INFO_API_KEY",
"KURSINFO_API_KEY",
"KURS_PM_DATA_API_KEY",
"REDIS_URI",
"SESSION_KEY",
Expand All @@ -24,7 +24,7 @@
"CONSOLE_ENABLED": "false",
"IMAGE_STORAGE_URI": "https://kursinfostorageprod.blob.core.windows.net/kursinfo-image-container/",
"KOPPS_URI": "https://api.kth.se/api/kopps/v2/?defaultTimeout=60000",
"KURS_INFO_API_URI": "https://api.kth.se/api/kursinfo?defaultTimeout=10000",
"KURSINFO_API_URI": "https://api.kth.se/api/kursinfo?defaultTimeout=10000",
"KURS_PM_DATA_API_URI": "https://api.kth.se/api/kurs-pm-data?defaultTimeout=10000",
"LOGGING_ACCESS_LOG": "true",
"LOGGING_LEVEL": "INFO",
Expand Down
4 changes: 2 additions & 2 deletions .azure/ref.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"APPLICATIONINSIGHTS_CONNECTION_STRING",
"KURSPLAN_API_KEY",
"KURSPLAN_API_URI",
"KURS_INFO_API_KEY",
"KURSINFO_API_KEY",
"KURS_PM_DATA_API_KEY",
"REDIS_URI",
"SESSION_KEY",
Expand All @@ -24,7 +24,7 @@
"CONSOLE_LOG": "true",
"IMAGE_STORAGE_URI": "https://kursinfostoragestage.blob.core.windows.net/kursinfo-image-container/",
"KOPPS_URI": "https://api-r.referens.sys.kth.se/api/kopps/v2/?defaultTimeout=60000",
"KURS_INFO_API_URI": "https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000",
"KURSINFO_API_URI": "https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000",
"KURS_PM_DATA_API_URI": "https://api-r.referens.sys.kth.se/api/kurs-pm-data?defaultTimeout=10000",
"LOGGING_ACCESS_LOG": "true",
"LOGGING_LEVEL": "TRACE",
Expand Down
22 changes: 4 additions & 18 deletions .env.in
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
# If KURS_PM_DATA_API_URI is omitted, http://localhost:3001/api/kurs-pm-data?defaultTimeout=10000 will be used
KURS_PM_DATA_API_URI=https://api-r.referens.sys.kth.se/api/kurs-pm-data?defaultTimeout=10000
# If KURS_PM_DATA_API_KEY is omitted, default key 1234 will be used
KURS_PM_DATA_API_KEY=[key]
KURS_PM_DATA_API_KEY=[Available in Azure KeyVault]
KURSINFO_API_KEY=[Available in Azure KeyVault]
KURSPLAN_API_KEY=[Available in Azure KeyVault]

# If KURS_INFO_API_URI is omitted, http://localhost:3002/api/kursinfo?defaultTimeout=10000 will be used
KURS_INFO_API_URI=https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000
# If KURS_INFO_API_KEY is omitted, default key 1234 will be used
KURS_INFO_API_KEY=[key]

# If KURSPLAN_API_URI is omitted, http://localhost:3003/api/kursplan?defaultTimeout=10000 will be used
KURSPLAN_API_URI=https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000
# If KURSPLAN_API_KEY is omitted, default key 5678 will be used
KURSPLAN_API_KEY=[key]

# If KOPPS_URI is omitted, https://api-r.referens.sys.kth.se/api/kopps/v2/?defaultTimeout=10000 will be used

SESSION_SECRET=[secret]
SESSION_KEY=[key]
REDIS_URI=[Available in Azure KeyVault]
53 changes: 1 addition & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,7 @@ Kurs-pm-web fetches data from:

### Secrets for Development

Secrets during local development are stored in a `.env` file in the root of your project. This file should be in `.gitignore`.

Secrets (names, passwords, keys, and uri:s) for dev and prod are stored in the the course information project’s Azure key vault.

```sh
# If KURS_PM_DATA_API_URI is omitted, http://localhost:3001/api/kurs-pm-data?defaultTimeout=10000 will be used
KURS_PM_DATA_API_URI=https://api-r.referens.sys.kth.se/api/kurs-pm-data?defaultTimeout=10000
# If KURS_PM_DATA_API_KEY is omitted, default key 1234 will be used
KURS_PM_DATA_API_KEY=[key]

# If KURS_INFO_API_URI is omitted, http://localhost:3002/api/kursinfo?defaultTimeout=10000 will be used
KURS_INFO_API_URI=https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000
# If KURS_INFO_API_KEY is omitted, default key 1234 will be used
KURS_INFO_API_KEY=[key]

# If KURSPLAN_API_URI is omitted, http://localhost:3003/api/kursplan?defaultTimeout=10000 will be used
KURSPLAN_API_URI=https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000
# If KURSPLAN_API_KEY is omitted, default key 5678 will be used
KURSPLAN_API_KEY=[key]

# If KOPPS_URI is omitted, https://api-r.referens.sys.kth.se/api/kopps/v2/?defaultTimeout=10000 will be used

SESSION_SECRET=[secret]
SESSION_KEY=[key]
```

These settings are also available in the `env.in` file.
Secrets during local development are stored in a gitignored `.env` file (`env.in` can be used as template for your `.env` file). More details about environment variable setup and secrets can be found in [confluence](https://confluence.sys.kth.se/confluence/x/OYKBDQ).

## For Development

Expand Down Expand Up @@ -172,31 +146,6 @@ docker-compose up

The deployment process is described in [Om kursen: Release till produktion](https://confluence.sys.kth.se/confluence/x/xIjCCg).

### Edit secrets.env

```sh
ansible-vault edit secrets.env
```

### Configure secrets.env

Secrets (names, passwords, keys, and uri:s) for dev and prod are stored in the the course information project’s Azure key vault.

```sh
KURS_PM_DATA_API_URI=localhost:portNumber/api/kurs-pm-data?defaultTimeout=10000
KURS_PM_DATA_API_KEY=[key]

KURS_INFO_API_URI=localhost:portNumber/api/kursinfo?defaultTimeout=10000
KURS_INFO_API_KEY=[key]

# If KOPPS_URI is omitted, pathToKopps/api/kopps/v2/?defaultTimeout=10000 will be used

SESSION_SECRET=[secret]
SESSION_KEY=[key]
APPLICATIONINSIGHTS_CONNECTION_STRING=[connection string]
REDIS_URI=[uri]
```

## Pre-\*\*-git-hooks

We use `husky` to run [pre-commit](/.husky/pre-commit) and [pre-push](/.husky/pre-push) hooks and `lint-staged` to run eslint and prettier.
Expand Down
10 changes: 5 additions & 5 deletions config/serverSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const {
const devPort = devDefaults(3000)
const devSsl = devDefaults(false)
const devUrl = devDefaults('http://localhost:' + devPort)
const devKursPmDataApi = devDefaults('http://localhost:3001/api/kurs-pm-data?defaultTimeout=10000')
const devKursInfoApi = devDefaults('http://localhost:3002/api/kursinfo?defaultTimeout=10000')
const devKursplanApi = devDefaults('http://localhost:3003/api/kursplan?defaultTimeout=10000')
const devKursPmDataApi = devDefaults('https://api-r.referens.sys.kth.se/api/kurs-pm-data?defaultTimeout=10000')
const devKursInfoApi = devDefaults('https://api-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000')
const devKursplanApi = devDefaults('https://api-r.referens.sys.kth.se/api/kursplan?defaultTimeout=10000')
const devKoppsApi = devDefaults('https://api-r.referens.sys.kth.se/api/kopps/v2/?defaultTimeout=10000')
const devSessionKey = devDefaults('kurs-pm-web.sid')
const devSessionUseRedis = devDefaults(true)
Expand All @@ -41,14 +41,14 @@ module.exports = {
// API keys
apiKey: {
kursPmDataApi: getEnv('KURS_PM_DATA_API_KEY', devDefaults('1234')),
kursInfoApi: getEnv('KURS_INFO_API_KEY', devDefaults('1234')),
kursInfoApi: getEnv('KURSINFO_API_KEY', devDefaults('1234')),
kursplanApi: getEnv('KURSPLAN_API_KEY', devDefaults('5678')),
},

// Service API's
nodeApi: {
kursPmDataApi: unpackNodeApiConfig('KURS_PM_DATA_API_URI', devKursPmDataApi),
kursInfoApi: unpackNodeApiConfig('KURS_INFO_API_URI', devKursInfoApi),
kursInfoApi: unpackNodeApiConfig('KURSINFO_API_URI', devKursInfoApi),
kursplanApi: unpackNodeApiConfig('KURSPLAN_API_URI', devKursplanApi),
},

Expand Down
4 changes: 2 additions & 2 deletions docker-compose-integration-tests-old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ services:
- LOGGING_ACCESS_LOG=true
- KURS_PM_DATA_API_URI=http://mock-api:3000/kurs-pm
- KURS_PM_DATA_API_KEY=secretpassword
- KURS_INFO_API_URI=http://mock-api:3000/kursinfo
- KURS_INFO_API_KEY=secretpassword
- KURSINFO_API_URI=http://mock-api:3000/kursinfo
- KURSINFO_API_KEY=secretpassword
- KURSPLAN_API_URI=http://mock-api:3000/kursplan
- KURSPLAN_API_KEY=secretpassword
- REDIS_URI=redis://redis:6379
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-performance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ services:
LOGGING_ACCESS_LOG: 'false'
KURS_PM_DATA_API_URI: 'http://mock-api:3000/kurs-pm'
KURS_PM_DATA_API_KEY: 'secretpassword'
KURS_INFO_API_URI: 'http://mock-api:3000/kursinfo'
KURS_INFO_API_KEY: 'secretpassword'
KURSINFO_API_URI: 'http://mock-api:3000/kursinfo'
KURSINFO_API_KEY: 'secretpassword'
KURSPLAN_API_URI: 'http://mock-api:3000/kursplan'
KURSPLAN_API_KEY: 'secretpassword'
REDIS_URI: 'redis://redis:6379'
Expand Down
Loading