Ninja-Squad / globe42

repository dedicated to the development of Globe 42 collective application to help them to manage their members
12 stars 3 forks source link

Build Status Codecov

Projet de gestion sécurisée des adhérents pour l'association Globe 42

Setup

Database

The project uses PostgreSQL as a database.

You need to install PostgreSQL on your machine. When this is done, run the database creation script:

psql -h localhost -U postgres -f backend/database/database.sql

Or, if you have Docker on your machine, you can run:

docker-compose up

Clever Cloud produces backups twice a day. You can import a backend locally to test with the real production data by executing the script backend/scripts/importBackupLocally.sh. (Read the instructions inside the script).

Backend

The project uses Spring (5.x) for the backend, with Spring Boot.

You need to install:

Then a the root of the application, run ./gradlew build to download the dependencies. Then run ./gradlew bootRun to start the app.

Frontend

The project uses Angular (4.x) for the frontend, with the Angular CLI.

You need to install:

Then in the frontend directory, run yarn to download the dependencies. Then run yarn start to start the app, using the proxy conf to reroute calls to /api to the backend.

The application will be available on http://localhost:4200

External services

The application stores uploaded documents in Google Cloud Storage. This means that the application needs credentials (which are json files generated by Google) in order to work fine.

Two separate accounts, and thus credentials files, are used:

We expect to stay inside the "Always Free" tier, whatever the account is.

Here are various interesting links regarding Google Cloud Storage (GCS):

Build

To build the app, just run:

./gradlew assemble

This will build a standalone jar at backend/build/libs/globe42.jar, that you can run with:

java -jar backend/build/libs/globe42.jar --globe42.secretKey=<some secret key>

And the full app runs on http://localhost:9000

By default, the default GCS credentials are used when launching the app this way. That means that the GCS APIs won't be accessible unless you set the GOOGLE_APPLICATION_CREDENTIALS as described in the documentation about default credentials

To avoid setting a global environment variable, you can instead use this command-line option:

--globe42.googleCloudStorage.credentialsPath=secrets/google-cloud-storage-dev.json

This credentials file is located in the Ninja Squad Drive

Deployment on CleverCloud

Here is our application management on Clever Cloud. All the ninjas are admin for this app (they need to log in with github).

Log to Clever and add your Public SSH key. In the left navigation bar, go in "Profile" and in the "SSH Keys" tab. Add the key by entering a name and the public SSH key (the key is the entire contents of the id_rsa.pub file). To check if your ssh key is correctly configured, you can try to run: ssh git@push.clever-cloud.com

Then clone locally the Git repository dedicated to the Clever deployment of Globe42 app : git clone git+ssh://git@push-par-clevercloud-customers.services.clever-cloud.com/app_5e422400-281d-499b-b34c-7555c2f7fadd.git

Inside this repo you have :

If you want to deploy a new version of the app:

That's it!

see the logs console and cross your fingers ;-)

Google Cloud Storage credentials on CleverCloud

Applications on CleverCloud don't have access to the file system. So, instead of defining an environment variable containing the path of the GCS credentials, we use an environment variable, globe42.googleCloudStorage.credentials, containing the content of the production credentials file.