Skip to content

Commit b4cf81a

Browse files
committed
Reorganized documentation for production
1 parent 6227672 commit b4cf81a

File tree

3 files changed

+67
-35
lines changed

3 files changed

+67
-35
lines changed

README.md

Lines changed: 61 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
- [Logging and logs rotation](./api/app/utils/Logger.py#L12)
2323
- [Choose](./app/app/src/App.js#L65) between sidebar and navbar (or use both !)
2424
- Responsive design
25-
- Production and development builds
25+
- [Production](./prod.docker-compose.yml) and [development](./docker-compose.yml) builds
2626

2727
## API documentation
2828

29-
I chose to use Swagger to document the API. Run the API following the steps below and go to [`http://localhost:5000`](http://localhost:5000).
29+
We've chosen Swagger to document the API. Run the API following the steps below and go to [`http://localhost:5000`](http://localhost:5000).
3030

3131
Here you can take a look at the database architecture scheme :
3232

@@ -44,11 +44,7 @@ With this boilerplate, you will be able to develop corporate-ready services AND
4444

4545
## Getting started (development)
4646

47-
The API is made to run with an LDAP server for managing users. Whether use the provided Docker LDAP server or remove the conf. in [`docker-compose.yml`](./docker-compose.yml) and use your own LDAP server.
48-
49-
This section will explain to you how to run this project and set-up the LDAP server with one user.
50-
51-
### 1. Starting authentication services
47+
This section will explain how to properly run this project and set-up the LDAP server with one user.
5248

5349
1. Copy the `.env.example` to `.env`
5450

@@ -58,52 +54,82 @@ This section will explain to you how to run this project and set-up the LDAP ser
5854

5955
> This is a good practice so your `.env` can't be committed along with your modifications (is in `.gitignore`)
6056
61-
2. Change the database/LDAP passwords and keys in `.env`
62-
63-
Then run :
57+
2. Start the authentication services
6458
6559
```bash
6660
docker-compose up ldap phpldapadmin database adminer -d
6761
```
6862
69-
- **adminer** (PostgreSQL management) will be available at `http://localhost:8082`
70-
- **phpLDAPAdmin** (LDAP management) will be available at `https://localhost:8081`
63+
- **phpLDAPAdmin** (LDAP management) will be available at `https://localhost:8081`
64+
- **adminer** (PostgreSQL management) will be available at `http://localhost:8082`
65+
66+
**Create** your first user by accessing phpLDAPAdmin at `https://localhost:8081` and [following the LDAP user creation guide](./CREATE_LDAP_USER.md).
67+
68+
3. NGINX reverse-proxy
69+
70+
This boilerplate includes NGINX as a reverse proxy so we can have a unique endpoint for our app and API. Else, we would have to open two endpoints : one for the app, the other for the API.
71+
72+
```bash
73+
docker-compose up --build -d nginx
74+
```
7175
72-
### 2. Creating the first user in the LDAP
76+
> NGINX will auto restart until you have started the app and API below.
7377
74-
Access phpLDAPAdmin at `https://localhost:8081` and [follow the LDAP user creation guide](./CREATE_LDAP_USER.md) to add your first user
78+
4. Run the API
7579
76-
### 3. NGINX reverse-proxy
80+
The database will be automatically set-up thanks to Flask Migrate and any future modification brought to [models](./api/app/model) will be automatically applied when the API is **restarted**.
7781
78-
This boilerplate includes NGINX as a reverse proxy so we can have a unique endpoint for our app and API. Else, we would have to open two endpoints : one for the app, the other for the API.
82+
You might wait some time before the database get updated after starting the API :
7983
80-
```bash
81-
docker-compose up --build -d nginx
82-
```
84+
```bash
85+
docker-compose up --build -d api
86+
```
8387
84-
NGINX will auto restart until you have started the app and API below.
88+
> For development, go to [`http://localhost:5000`](http://localhost:5000) to access the API documentation
8589
86-
### 4. Run the API
90+
5. Run the web app
8791
88-
The database will be automatically set-up thanks to Flask Migrate and any future modification brought to [models](./api/app/model) will be automatically applied when the API is **restarted**.
92+
```bash
93+
# Expect several minutes for first launch (npm install)
94+
docker-compose up --build -d app
95+
```
8996
90-
You might wait some time before the database get updated after starting the API :
97+
> :information_source: If you want to add a NPM package, just stop & re-launch `docker-compose up app`.
9198
92-
```bash
93-
docker-compose up --build -d api
94-
```
99+
Enjoy the app on [`http://localhost:8080`](http://localhost:8080)
95100
96-
> For development, go to [`http://localhost:5000`](http://localhost:5000) to access the API documentation
101+
## Deploy to production
97102
98-
### 5. Run the web application
103+
1. Prepare environment configuration
99104
100-
:clock9: NPM's initial install may take quite a lot of time
105+
Copy `.env.example` to `.env` and **edit** the passwords, keys and credentials
101106
102-
```bash
103-
# Expect several minutes for first launch (npm install)
104-
docker-compose up --build -d app
105-
```
107+
Use the provided Docker LDAP server or edit the config to use your own.
106108
107-
Enjoy the app on [`http://localhost:8080`](http://localhost:8080)
109+
```bash
110+
cp .env.example .env
111+
```
112+
113+
2. Build the application for production
114+
115+
```bash
116+
docker-compose -f prod.docker-compose.yml build
117+
```
118+
119+
3. Start the authentication services
120+
121+
```bash
122+
docker-compose up ldap phpldapadmin database adminer -d
123+
```
124+
125+
**Create** your first user by accessing phpLDAPAdmin at `https://localhost:8081` and [following the LDAP user creation guide](./CREATE_LDAP_USER.md).
126+
127+
:information_source: We recommend you to hide this service behind a firewall
128+
129+
4. Run the application
130+
131+
```bash
132+
docker-compose -f prod.docker-compose.yml up nginx api app -d
133+
```
108134
109-
> :information_source: If you want to add a NPM package, just stop & re-launch `docker-compose up app`.
135+
Access the UI at `https://localhost:8080`

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ services:
8585
volumes:
8686
- ./nginx/proxy.conf:/etc/nginx/conf.d/proxy.conf:ro
8787
- ./logs/nginx:/var/log/nginx
88+
depends_on:
89+
- api
90+
- app
8891

8992
volumes:
9093
database:

prod.docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ services:
7777
- "8080:80"
7878
volumes:
7979
- nginx_logs:/var/log/nginx
80+
depends_on:
81+
- api
82+
- app
8083

8184
volumes:
8285
api_logs:

0 commit comments

Comments
 (0)