UNHCR Geneva Technical Hub App
Currently under development, release 1.0 expected March 2023, then user testing.
- go to https://github.com/EPFL-ENAC/unhcr-geneva-tech-hub-app/blob/main/frontend/src/assets/references/ghg_reference.json
- Click on the 'edit this file' button (small pencil icon on the top)
- Edit file and click on 'commit changes' button
- On the popup select 'create a new branch' instead of 'commit directly to main branch'
- On the pull request page
- Edit the description
- Add the 'ghg' tag at least
- Add the appropriates assignees, milestones and projects
- Click on 'create pull request
![create_pull-request](https://private-user-images.githubusercontent.com/161889/242579446-8b099d0d-dfce-4e4b-ba09-8d9d8b68c4fa.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1ODI0NTEsIm5iZiI6MTczOTU4MjE1MSwicGF0aCI6Ii8xNjE4ODkvMjQyNTc5NDQ2LThiMDk5ZDBkLWRmY2UtNGU0Yi1iYTA5LThkOWQ4YjY4YzRmYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNVQwMTE1NTFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mNjJkY2JkMTI1NWM3MzIxY2ZhY2I0MWRkMjc1MGRjY2I2N2RhNGJjZDQwMzcwOWRlYjAwM2YxMzNiZDZhYTk3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.B75FirocJm5fSTxSzXGfCamf9IsfYXKHupGBdx-cisI)
- We use husky for git hooks: https://typicode.github.io/husky/#/?id=install
- We use standard version and commitlint for automatic release log and proper commit message
Prerequisites:
- Make (gnu make)
- Node.js 16.x
- use nvm https://github.com/nvm-sh/nvm#installing-and-updating
- nvm install --lts; nvm use --lts
- [yarn]
- Docker
- Docker Compose 1.27.0+
An environment file should be created; you may copy paste the following code, don't forget to replace by the appropriate bucket name and HOSTNAME
tee -a .env << EOF
COUCHDB_USER=admin
COUCHDB_PASSWORD=couchdb
COUCHDB_HOST=localhost
# EPFL DNS
DNS=128.178.15.8
# used by nginx s3 service and fast api boto api
S3_ENDPOINT_HOSTNAME=s3.epfl.ch
S3_ENDPOINT_PROTOCOL=https://
S3_ACCESS_KEY_ID=XXXXXX_REPLACE__ME_XXX
S3_SECRET_ACCESS_KEY=XXXXXX_REPLACE__ME_XXX
S3_REGION=EU
S3_Bucket=XXXXXX_REPLACE__ME_XXX
# for instance if S3_Key is foo/bar/ ; the url will start with: /s3/foo/bar/
S3_Key=XXXXXX_REPLACE__ME_XXX
EOF
make install
make run-database;
make setup-database;
make run-frontend;
# http://127.0.0.1:8080
Run configurations are in .vscode
: https://code.visualstudio.com/docs/editor/debugging
make run # will build with docker-compose and run docker-compose up -d
We use enacit-ansible to automate our process
Just run the following command and it will install the latest commit from the main branch
ansible-playbook -v -i inventory/unhcr-tss.epfl.ch.yml playbooks/deploy-app.yml
- If you change couchdb-setup/etc/config.ini file
- You'll need to do the following:
ssh unhcr-tss.epfl.ch # wait to be connected cd /opt/unhcr-tss; docker-compose restart couchdb;
- same for unhcr-tss-test.epfl.ch
- You'll need to do the following:
- regular (at least weekly) releases onto the staging environment - http://unhcr-tss-test.epfl.ch/ accessible within EPFL only.
- monthly (by the 1st) releases onto the production environment http://unhcr-tss.epfl.ch/ including only features validated.
- intermediate releases may happen occasionally for hot fixes
Releases number follow [semantic versioning conventions](https://semver.org/\).
There is two way of doing this: first one using curl; second one using couchdb-bootstrap
curl -X PUT http://localhost:5984/_users/org.couchdb.user:newuser@epfl.ch \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"name": "newuser@epfl.ch", "password": "plain_text_password_that_will_be_encrypted", "roles": [], "type": "user"}'
- retrieve the inserted documented
curl -X GET http://admin:couchdb@localhost:5984/_users/org.couchdb.user:newuser@epfl.ch \
-H "Accept: application/json" \
-H "Content-Type: application/json"
{"_id":"org.couchdb.user:newuser@epfl.ch","_rev":"1-xxxx","name":"newuser@epfl.ch","roles":[],"type":"user","password_scheme":"pbkdf2","iterations":10,"derived_key":"917a923abd865bc82feadd5659a1d0d55318ca49","salt":"83f9a989d48e31b7a5e99c28df8a989c"}
- add the result json from above inside
add the above json result as new file in
couchdb-setup/bootstrap/_users/newuser@epfl.ch.json
: 3.a you can remove the _rev field
{
"_id": "org.couchdb.user:newuser@epfl.ch",
"name": "newuser@epfl.ch",
"roles": [],
"type": "user",
"password_scheme": "pbkdf2",
"iterations": 10,
"derived_key": "917a923abd865bc82feadd5659a1d0d55318ca49",
"salt": "83f9a989d48e31b7a5e99c28df8a989c"
}
- add a new file inside couchdb-setup/bootstrap/_users with
{
"_id": "org.couchdb.user:newuser@epfl.ch",
"name": "newuser@epfl.ch",
"roles": [],
"type": "user",
"password": "plain_text_that_will_be_hash_by_couchdb",
}
- run the following command:
make setup-database
- CouchDB has hashed the password, you can get it on http://localhost:5984/\_utils/#database/\_users/\_all_docs
- find the new user and download
- save the document by deplacing
couchdb-setup/bootstrap/_users/new_username.json
- remove the
'_rev'
field and commit the file
- run make azure
make azure
- then copy the content of the json
azure/jwt_keys.json
at the proper place inside couchdb-setup/bootstrap/_config.json - verify that the json is valid
- 2 services necessary
- nginx proxy to our custom epfl s3 instance
- python fast api using boto3 to upload files to the s3 instance We don't store the uploaded file directly to a database, it should be done by the frontend by talking directly to couchdb. The API just return the path served by the nginx reverse proxy