You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-28
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ To run the application manually in a terminal, see both the [backend](backend/RE
30
30
31
31
## Running the application with Docker
32
32
33
-
The project contains Docker configuration files to run the application with Docker compose. Two docker-compose files are provided with configuration for `dev` and for `production` environments. The Docker configuration is largely adapted from Tiangolo's [Full stack FastAPI cookiecutter](https://github.com/tiangolo/full-stack-fastapi-postgresql) project.
33
+
The project contains Docker configuration files to run the application with Docker compose. Two docker-compose files are provided with configuration for `dev` and for `production` environments. The Docker configuration is largely adapted from Tiangolo's [Full stack FastAPI template](https://github.com/fastapi/full-stack-fastapi-template) project.
34
34
35
35
### Local development with Docker
36
36
@@ -39,16 +39,14 @@ The local development file for docker is [docker-compose.yml](./docker-compose.y
39
39
Start the stack with Docker Compose:
40
40
41
41
```bash
42
-
docker compose up -d --build
42
+
docker compose watch
43
43
```
44
44
45
-
The `--build` arg can be omitted after the images have been built at least once.
46
-
47
-
Now you can open your browser and interact with these URLs:
45
+
You can then open your browser and interact with these URLs:
48
46
49
47
* Frontend, served with vite with hot reload of code: http://localhost
50
48
51
-
* Backend, JSON based web API based on OpenAPI, with hot code reloading: http://localhost/api/
49
+
* Backend, JSON based web API based on OpenAPI, with hot code reloading: http://localhost/api/v1
52
50
53
51
* Automatic interactive documentation with Swagger UI (from the OpenAPI backend): http://localhost/docs
54
52
@@ -68,30 +66,12 @@ To check the logs of a specific service, add the name of the service, e.g.:
68
66
docker compose logs backend
69
67
```
70
68
71
-
### Docker Compose settings for development
72
-
73
-
When running the application with docker in development, both the frontend and backend directories are mounted as volumes to their corresponding docker containers to enable hot reload of code changes. This allows you to test your changes right away, without having to build the Docker image again. It should only be done during development, for production you should build the Docker image with a recent and stable version of the code.
74
-
75
-
For the backend, there is a command override that runs `/start-reload.sh` (included in the base image) instead of the default `/start.sh` (also included in the base image). It starts a single server process (instead of multiple, as would be for production) and reloads the process whenever the code changes. Have in mind that if you have a syntax error and save the Python file, it will break and exit, and the container will stop. After that, you can restart the container by fixing the error and running the `docker-compose up -d` command again. The backend [Dockerfile](backend/Dockerfile) is in the backend directory.
76
-
77
-
For the frontend, when in development, the frontend docker container starts with the `npm run dev -- --host` command, while in production the frontend app is built into static files and the app is served by an nginx server. The [nginx configuration file](frontend/nginx.conf) is in the frontend dir.
78
-
79
-
### Accessing the containers
80
-
81
-
To get inside a container with a `bash` session you can start the stack with:
82
-
83
-
```console
84
-
$ docker compose up -d
85
-
```
86
-
87
-
and then `exec` inside the running container:
69
+
To get access to a bash session inside a container (e.g. the `backend`):
88
70
89
71
```console
90
72
$ docker compose exec backend bash
91
73
```
92
74
93
-
This will give you access to a bash session in the `backend` container. Change the name of the container to the one you want to access.
94
-
95
75
96
76
### Docker Compose settings for production
97
77
@@ -103,13 +83,15 @@ docker compose -f docker-compose.prod.yml up -d
103
83
104
84
**Note:** This will not work out of the box, mainly because the `docker-compose-prod.yml` configures a traefik proxy with ssl enabled that will try to fetch ssl certificates from Let's Encrypt, which will not work unless you specify a valid hostname accessible on the internet. However, to deploy the application in production on a server, you only need to set the required env variables in the [.env](./.env) file.
105
85
86
+
When using the production configuration, the frontend app is built into static files and the app is served by an nginx server. The [nginx configuration file](frontend/nginx.conf) is in the frontend dir.
87
+
106
88
### Docker Compose files and env vars
107
89
108
90
Both the [docker-compose.yml](./docker-compose.yml) and [docker-compose-prod.yml](./docker-compose.prod.yml) files use the [.env](./.env) file containing configurations to be injected as environment variables in the containers.
109
91
110
-
The docker-compose files are designed to support several environments (i.e. development, building, testing, production) simply by setting the appropriate variable values in the `.env` file.
92
+
The docker-compose files are designed to support several environments (i.e. development, testing, production) simply by setting the appropriate variable values in the `.env` file.
111
93
112
-
The [.env](./.env) file contains all the configuration variables. The values set in the `.env` file will override those that are set in the frontend and backend `.env` files for local development. For exemple, the backend app also has a [.env.dev](backend/.env.dev) file which is read to populate the backend's [config](backend/app/config/config.py) module. When the application is run with docker though, the env variables in the projet root's [.env](./.env) file will override the env variables set in the backend and frontend's respective .env files. In order to be able to keep working both with docker and manually, you only have to make sure that the required variables are set both in the root `.env` file, and in the backend and frontend `.env` files.
94
+
The [.env](./.env) file contains all the configuration variables. The values set in the `.env` file will override those that are set in the frontend `.env` files for local development.
113
95
114
96
The `.env` file that is commited to the github repository contains example values which are ok to use for testing and development, but which should be changed when running the application in production (admin passwords, secret keys, client ids, etc.). During deployment in production, the .env file is replaced with one containing the appropriate values.
115
97
@@ -119,7 +101,7 @@ To setup SSO and enable the `Sign-In with Google` button, you must first obtain
119
101
120
102
Create a new project, and from the `APIs & Services` menu, first create an `OAuth consent screen` for you application, then add an `OAuth 2.0 Client Id` in the `Credentials` menu. Select `Web application` as the application type. In the `Authorized redirect URIs`, add your hostname with the `api/v1/login/google/callback` endpoint. For instance, if testing locally while running the backend app with `uvicorn`, add `http://localhost:8000/api/v1/login/google/callback` (use `http://localhost/api/v1/login/google/callback` if running the application in dev with docker). If your application is hosted on a domain name, add it to the list of URIs (remember to update `http` to `https` when using SSL).
121
103
122
-
Once you've create a client-id and token in your Google cloud console, copy those into your `.env` file's (either directly in the backend [.env](./backend/.env.dev) or in the root [.env](./.env) if using docker) `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET` variables.
104
+
Once you've create a client-id and token in your Google cloud console, copy those into your `.env` file's `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET` variables.
123
105
124
106
## Setting up automatic build of the docker images in github
Copy file name to clipboardExpand all lines: backend/README.md
+7-7
Original file line number
Diff line number
Diff line change
@@ -9,22 +9,22 @@ This directory contains the backend API app. It is built with [FastAPI](https://
9
9
10
10
## Install
11
11
12
-
The project uses poetry to manage dependencies. You can use your own environment, or use poetry to manage the virtuel env and the project depencencies.
12
+
The project uses poetry to manage dependencies and run the backend application. You can use an other tool to manage your virtual environment, such as `pip`or [uv](https://docs.astral.sh/uv/), but you'll need to extract the dependencies from the [pyproject.toml](./pyproject.toml) file.
13
13
14
14
If using poetry, for convenience, run `poetry config virtualenvs.in-project true` before installing depencies. This will install the dependencies in the project directory and make it easier to manage in vscode.
15
15
16
16
You can then install the dependencies with `poetry install --with dev`.
17
17
18
-
To activate the virtual env, use `poetry shell`.
19
-
20
18
## Running the server
21
19
22
-
Run this command to start a development server :
20
+
To start a development server, run
23
21
24
22
```console
25
-
uvicorn app.main:app --reload
23
+
poetry run fastapi dev app/main.py
26
24
```
27
25
26
+
from the `backend` directory (remove the `poetry run` prefix if using another dependency management tool).
27
+
28
28
This will start a server running on `http://127.0.0.1:8000`. The API will be available on the API's base prefix, which by default is `/api/v1`.
29
29
30
30
Navigate to `http://localhost:8000/api/v1/` to access the root API path.
@@ -36,10 +36,10 @@ Navigate to `http://localhost:8000/redoc` to access the API's alternative doc bu
0 commit comments