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
{{ message }}
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
* Lower postgres restart policy
* Add a backup script to postgres db to run in cron.daily
* Add an option to login to api view
* Fix server test
* Add Database Backups section to README
* Edit README file
* Edit README file take 2
* Try different indentation
* Fix tests take 1
* Fix tests teke 2
The `server` directory contain a simple [Django](https://www.djangoproject.com/) app that expose an `api` of Django `users` with [Django REST framework](http://www.django-rest-framework.org/). The `client` directory contain an [Angular](https://angular.io/) simple app, built with [Angular-Cli](https://github.com/angular/angular-cli), [ngrx](https://github.com/ngrx) to handle state, [Angular Material](https://github.com/angular/material2) as a design library, have service worker, and ready to `AOT` compilation. The simple Angular app show the users from the Django api.
5
+
This repo is a production ready seed project. The app shows a list of users.
6
6
7
-
The repo is a production ready app, that uses `nginx` to serve static files (the client app and static files from the server), and `gunicorn` for the server (python) stuff. All the parts are in a separate [Docker](https://www.docker.com/) containers and we use [Docker Swarm](https://docs.docker.com/engine/swarm/) to manage them.
7
+
## Structure
8
8
9
-
We use [ELK Stack](https://www.elastic.co/products) for logging. The `server` and the `client` logs sent to logstash, and saved in elasticsearch. There is also a kibana instance to check and analyze all the logs.
9
+
* The `client` service is a build of the `client` directory. It contain an [Angular](https://angular.io/) app, built with [Angular-Cli](https://github.com/angular/angular-cli), [ngrx](https://github.com/ngrx) to handle state, [Angular Material](https://github.com/angular/material2) as a design library, have service worker, and `AOT` compiled. The app shows the users from the Django api.
10
+
* The `server` service is a build of the `server` directory. It contain a simple [Django](https://www.djangoproject.com/) app that expose an `api` of Django `users` with [Django REST framework](http://www.django-rest-framework.org/). The Python serve through a [gunicorn](http://gunicorn.org/) server installed in the container.
11
+
* There is a `postgres` service for the Django database. The `database` directory contains the automatic backup script.
12
+
* There is an `nginx` service to serve static files (the client app).
13
+
* There is an `haproxy` service to get all the HTTP requests and do load balancing between the containers in the services.
14
+
* There are a separate containers for the [ELK Stack](https://www.elastic.co/products) for logging. The `server` and the `client` logs sent to logstash, and saved in elasticsearch. There is also a kibana instance to check and analyze all the logs.
15
+
* There is a `visualizer` container to visualize where is each container is located at (on which server).
16
+
17
+
All the parts are in a separate [Docker](https://www.docker.com/) containers and we use [Docker Swarm](https://docs.docker.com/engine/swarm/) to manage them.
10
18
11
19
## Pre Requirements
12
20
@@ -19,10 +27,18 @@ Automatic installation of the project with docker, for development.
19
27
1. In `client` directory run `docker build -t client .` to build the Docker image.
20
28
2. In `server` directory run `docker build -t server .` to build the Docker image.
21
29
3. To create a swarm `docker swarm init`.
22
-
4. Run `docker stack deploy --compose-file=docker-compose.yml prod`
23
-
5. Open the browser at [http://localhost](http://localhost) to see your Angular (client) app.
24
-
6. Open the browser at [http://localhost:8000](http://localhost:8000) to see your Django (server) app.
25
-
7. Open the browser at [http://localhost:5601](http://localhost:5601) to see Kibana and check your logs.
30
+
4. Download all docker images:
31
+
*`docker pull dockercloud/haproxy`
32
+
*`docker pull postgres`
33
+
*`docker pull dockersamples/visualizer:stable`
34
+
*`docker pull elasticsearch:5.4.3`
35
+
*`docker pull kibana:5.4.3`
36
+
*`docker pull logstash:5.4.3`
37
+
5. Run `docker stack deploy --compose-file=docker-compose.yml prod`
38
+
6. Open the browser at [http://localhost](http://localhost) to see your Angular (client) app.
39
+
7. Open the browser at [http://localhost:8000](http://localhost:8000) to see your Django (server) app.
40
+
8. Open the browser at [http://localhost:8080](http://localhost:8080) to see the visualizer.
41
+
9. Open the browser at [http://localhost:5601](http://localhost:5601) to see Kibana and check your logs.
26
42
27
43
**If you want to install the project manually, go to the `/client` or `/server` directories and read the `README` file.**
28
44
@@ -52,7 +68,25 @@ Automatic installation of the project with docker, for development.
52
68
53
69
There is already tests for the `server` and the `client`, we currently at **+90** percent coverage.
54
70
55
-
We also write some tests for doing load test with [locust](http://locust.io/), you can find it under `server/locustfile.py`. To do a load test just install locust (it's in the `requirements.txt` file) go to `server` directory and
71
+
To run the `client` tests and lint run the commands below in the `client` directory.
72
+
73
+
```
74
+
npm run lint
75
+
npm run test
76
+
```
77
+
78
+
To run the `server` tests and lint run the commands below in the `server` directory.
We also write some tests for doing load test with [locust](http://locust.io/), you can find it under `server/locustfile.py`.
88
+
89
+
To do a load test just install locust (it's in the `requirements.txt` file) go to `server` directory and run
56
90
57
91
```
58
92
locust --host=http://localhost
@@ -74,6 +108,16 @@ And then update the service with the new image
74
108
docker service update --image server:v2 prod_server
75
109
```
76
110
111
+
## Database Backups
112
+
113
+
Each day a backup of the PostgreSQL database will be created. The daily backups are rotated weekly, so maximum 7 backup files will be at the daily directory at once.
114
+
115
+
Each Saturday morning a weekly backup will be created at the weekly directory. The weekly backups are rotated on a 5 week cycle.
116
+
117
+
Each month at the 1st of the month a monthly backup will be created at the monthly directory. Monthly backups are **NOT** rotated
118
+
119
+
The backups are saved at `/var/backups/postgres` at the host machine via a shared volume. It can be configured in the `docker-compose.yml` at `volumes` section of the `database` service.
0 commit comments