https://github.com/codeworksfrance/codetestback
https://github.com/codeworksfrance/codetestback
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codeworksfrance/codetestback
- Owner: CodeWorksFrance
- Created: 2021-02-26T09:09:29.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-23T14:52:45.000Z (almost 5 years ago)
- Last Synced: 2025-03-16T22:26:43.471Z (about 1 year ago)
- Language: Python
- Size: 95.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# CodeTestBack
## GCP Configuration
* **Project ID** : code-test-back
* **Region** : europe-west1
* **Zone** : europe-west1-b
* **Cloud Run Service** : code-test-back-service
* **Cloud Build** : code-test-back-trigger
* **Enabled Services** :
* Enable Cloud Run API
* Enable Cloud Build
* Enable Container Register
* Enable Cloud SQL Admin API
* **Authorization**:
* **CodeTestBack** -> **IAM & Admin** -> **Service Accounts** -> **Copy the service account**
* **CodeTestBDD** -> **IAM & Admin** -> **IAM page** -> **ADD** -> **Past the service account and give the Cloud SQL
Client Role**
## Running locally
To run this application locally, download and install the `cloud_sql_proxy` by following the
instructions [here](https://cloud.google.com/sql/docs/postgres/sql-proxy#install).
Instructions are provided below for using the proxy with a TCP connection or a Unix Domain Socket. On Linux or Mac OS
you can use either option, but on Windows the proxy currently requires a TCP connection.
### Launch proxy with TCP
To run the sample locally with a TCP connection, set environment variables and launch the proxy as shown below.
#### Linux / Mac OS
Use these terminal commands to initialize environment variables:
* Init environment variables
```bash
chmod 775 init_db_vars.sh
source ./init_db_vars.sh
```
Note: Saving credentials in environment variables is convenient, but not secure - consider a more secure solution such
as [Secret Manager](https://cloud.google.com/secret-manager/docs/overview) to help keep secrets safe.
* Then use this command to launch the proxy in the background:
```bash
./cloud_sql_proxy -instances=codetestbdd:europe-west1:codetest-bdd-1=tcp:5432 &
```
* To stop the proxy :
Find process :
```bash
ps | grep cloud_sql_proxy
```
Kill process based on its id
```bash
kill process_id
```
### Configure your local Postgres Client using the Cloud SQL PROXY
Host : localhost
Port : 5432
User : Postgres
Pass : CodeWorks
Database : postgres
### Install Pipenv Globally
1. Open Terminal in (Applications/Utilities/Terminal) and upgrade pip:
```bash
python3.8 -m pip install pip --upgrade
```
Another option to upgrade, is:
```bash
pip3 install pip --upgrade
```
2. Install Pipenv:
```bash
python3.8 -m pip install pipenv
```
Another option to upgade, is :
```bash
pip3 install pipenv --upgrade
```
3. Verify Pipenv:
```bash
pipenv
```
### Testing the application
```bash
virtualenv --python python3 env
source env/bin/activate
pip install -r requirements.txt
`````
Finally, start the application:
```bash
strawberry server app
```
Navigate towards `http://127.0.0.1:8000` or `http://localhost:8000` to verify your application is running correctly.