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
+4-71Lines changed: 4 additions & 71 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
# Flask API REST Template
2
-
Rest API template developed in Python with the Flask framework. The template covers user management, jwt tokens for authentication, and assign permissions for each user with Flask Principal. In the local environment, it uses docker to create an environment made up of several services such as api (flask), database (postgresql), swagger (swagger-ui), reverse-proxy (nginx), cron to perform database backups automatically.
3
-
2
+
Rest API template developed in Python with the Flask framework. The template covers user management, jwt tokens for authentication, and assign permissions for each user with Flask Principal. In the local environment, it uses docker to create an environment made up of several services such as api (flask), database (postgresql), reverse-proxy (nginx).
4
3
## Index
5
4
-[Technology](#technology)
6
5
-[Requirements](#requirements)
@@ -9,7 +8,6 @@ Rest API template developed in Python with the Flask framework. The template cov
9
8
-[Testing](#testing)
10
9
-[Local](#local)
11
10
-[Production](#production)
12
-
-[Backups](#backups)
13
11
-[Flask Commands](#flask-commands)
14
12
-[Flask-cli](#flask-cli)
15
13
-[Database commands](#bbdd-commands)
@@ -23,11 +21,10 @@ Rest API template developed in Python with the Flask framework. The template cov
23
21
-**Web Framework:** Flask
24
22
-**ORM:** Flask-sqlalchemy
25
23
-**Swagger:** Swagger-UI
26
-
-**Authentication:**JSON Web Token
24
+
-**Authentication:**Flask Json Web Token
27
25
-**Permission:** Flask Principal
28
26
-**Serialization, Deserialization and Validation:** Marshmallow
29
27
-**Migration Database:** Flask-migrate
30
-
-**Authentication:** Flask-jwt-extended
31
28
-**Environment manager:** Anaconda/Miniconda
32
29
-**Containerization:** Docker, docker-compose
33
30
-**Database:** PostgreSQL
@@ -214,8 +211,8 @@ Testing environment that uses PostgreSQL as database (db_test) and performs unit
214
211
### Local
215
212
Containerized services separately with PostgreSQL databases (db), API (api) and Nginx reverse proxy (nginx) with Docker and docker-compose.
216
213
217
-
1. Create **.env.api.local**, **.env.db.local**and **.env.cron.local**files and enter environment variables for
218
-
each service. In the local environment there are 4 services (api, db, nginx, cron). For example:
214
+
1. Create **.env.api.local**, **.env.db.local** files and enter environment variables for
215
+
each service. In the local environment there are 3 services (api, db, nginx). For example:
219
216
1. **.env.api.local**:
220
217
```shell
221
218
# APP configuration
@@ -250,58 +247,7 @@ Containerized services separately with PostgreSQL databases (db), API (api) and
250
247
251
248
POSTGRES_DB=<name_DB> # For example db_dev
252
249
```
253
-
3. **.env.cron.local**:
254
-
```shell
255
-
# Service configuration DB backups
256
250
257
-
# User to access the database server, example root
258
-
BBDD_USER=<name_user># For example root
259
-
260
-
# Password to access the postgresql database
261
-
PGPASSWORD=<password> # For example password
262
-
263
-
# Host name (or IP address) of the PostgreSQL server, example localhost
264
-
DB_HOST=<host> # For example db (name service in docker-compose)
265
-
266
-
# PostgreSQL server port, example 5432
267
-
BBDD_PORT=<port> # For example 5432 (port service in docker-compose)
268
-
269
-
# Type of database
270
-
DATABASE=<database_type> # For example postgres
271
-
272
-
# List of DBNAMES for Daily/Weekly Backup e.g. "DB1DB2DB3"
273
-
BACKUPS_DBNAMES=<tables> # For example all
274
-
275
-
# Backup directory location e.g. /backups
276
-
BACKUPS_BACKUPDIR=<backups_dir> # For example /var/backups/postgres
277
-
278
-
# LOG directory location
279
-
BACKUPS_LOGDIR=<dir_logs> # For example /var/log
280
-
281
-
# List of DBNAMES to EXLUCDE if DBNAMES are set to all (must be in " quotes)
282
-
BACKUPS_DBEXCLUDE=<tables> # For example db_test root postgres template0 template1
283
-
284
-
# Include CREATE DATABASE in backup?
285
-
BACKUPS_CREATE_DATABASE=<yes_or_no> # For example yes
286
-
287
-
# Separate backup directory and file for each DB? (yes or no)
288
-
BACKUPS_SEPDIR=<yes_or_no> # For example yes
289
-
290
-
# Which day do you want weekly backups? (1 to 7 where 1 is Monday)
291
-
BACKUPS_DOWEEKLY=<day_week> # For example 7
292
-
293
-
# Which day do you want monthly backups? (1 to 28)
294
-
BACKUPS_DOMONTHLY=<day_month> # For example 1
295
-
296
-
# Choose Compression type. (gzip or bzip2)
297
-
BACKUPS_COMP=<compression_type> # For example bzip2
298
-
299
-
# Command to run before backups (uncomment to use)
300
-
#BACKUPS_PREBACKUP=<command> # For example /etc/pgsql-backup-pre
301
-
302
-
# Command run after backups (uncomment to use)
303
-
#BACKUPS_POSTBACKUP=<command> # For example sh /home/backups/scripts/ftp_pgsql
304
-
```
305
251
2. Run:
306
252
1. Build and run services:
307
253
```shell
@@ -357,19 +303,6 @@ Apply CI/CD with Github Actions to automatically deployed to AWS platform use EC
357
303
2. **AWS_SECRET_ACCESS_KEY**: secret access
358
304
3. **AWS_DEFAULT_REGION**: region
359
305
360
-
## Backups
361
-
In the local environment there is a service called `cron` and it is in charge of executing a script that performs a backup
362
-
from the database, in this case from postgresql. The script is run daily by cron and makes a copy
363
-
daily, weekly and monthly.
364
-
365
-
- `Daily` backups are rotated weekly.
366
-
- `weekly` backups are run by default on Saturday morning when cron.daily scripts are executed.
367
-
It can be changed with the `DOWEEKLY` setting. Weekly backups are rotated on a 5-week cycle.
368
-
- `Monthly` backups run on the 1st of every month. It can be changed with the `DOMONTHLY` setting.
369
-
Monthly backups are NOT automatically rotated.
370
-
371
-
**Note:** It may be a good idea to copy the monthly backups offline or to another server.
0 commit comments