File tree Expand file tree Collapse file tree 8 files changed +180
-0
lines changed Expand file tree Collapse file tree 8 files changed +180
-0
lines changed Original file line number Diff line number Diff line change
1
+ COMPOSE_PROJECT_NAME = ' fastapi-vuejs-template'
2
+ DB_USERNAME = root
3
+ DB_PASSWORD = password
4
+ MONGO_INITDB_DATABASE = core
5
+ DATABASE_URL = mongodb://root:password@db:27017
6
+ NODE_ENV = development
7
+ DEBUG = 1
8
+ SECRET_KEY = " gscworking"
Original file line number Diff line number Diff line change
1
+ [submodule "fastapi-template "]
2
+ path = backend
3
+ url = https://github.com/gsc2001/fastapi-template.git
4
+ [submodule "vuejs-template "]
5
+ path = frontend
6
+ url = https://github.com/gsc2001/vuejs-template.git
Original file line number Diff line number Diff line change
1
+ #### FastAPI / VueJS docker template
2
+
3
+ fastapi and vuejs application in docker-compose
4
+
5
+ ##### Steps
6
+
7
+ Needs docker and docker-compose
8
+
9
+ - Copy .env
10
+
11
+ ``` bash
12
+ $ cp -rv env.example .env
13
+ ```
14
+
15
+ - Populate .env
16
+
17
+ - Docker
18
+
19
+ ` ` ` bash
20
+ $ docker-compose up -d
21
+ ` ` `
Original file line number Diff line number Diff line change
1
+ upstream backend_server {
2
+ server backend:5000;
3
+ }
4
+
5
+ upstream frontend_server {
6
+ server frontend:8080;
7
+ }
8
+
9
+ upstream db_interface {
10
+ server db_interface:8081;
11
+ }
12
+
13
+ # now we declare our main server
14
+ server {
15
+
16
+ listen 80;
17
+ server_name localhost;
18
+ client_max_body_size 8M;
19
+
20
+ location /static/ {
21
+ proxy_pass http://backend_server/static/;
22
+ }
23
+
24
+ location /db_interface/ {
25
+ proxy_pass http://db_interface;
26
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
27
+ proxy_set_header Host $host;
28
+ proxy_redirect off;
29
+ }
30
+
31
+ location /api/ {
32
+ proxy_pass http://backend_server/;
33
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
34
+ proxy_set_header Host $host;
35
+ proxy_redirect off;
36
+ }
37
+
38
+ location / {
39
+ proxy_pass http://frontend_server/;
40
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
41
+ proxy_set_header Host $host;
42
+ proxy_redirect off;
43
+ }
44
+
45
+
46
+ }
Original file line number Diff line number Diff line change
1
+ version : ' 3.1'
2
+ services :
3
+ db :
4
+ image : mongo
5
+ restart : always
6
+ networks :
7
+ - db_network # for api reqs
8
+ environment :
9
+ MONGO_INITDB_ROOT_USERNAME : $DB_USERNAME
10
+ MONGO_INITDB_ROOT_PASSWORD : $DB_PASSWORD
11
+ MONGO_INITDB_DATABASE : $MONGO_INITDB_DATABASE
12
+ volumes :
13
+ - db_vol:/data/db
14
+
15
+ db_interface :
16
+ image : mongo-express
17
+ restart : always
18
+ environment :
19
+ ME_CONFIG_MONGODB_ADMINUSERNAME : $DB_USERNAME
20
+ ME_CONFIG_MONGODB_ADMINPASSWORD : $DB_PASSWORD
21
+ ME_CONFIG_SITE_BASEURL : /db_interface/
22
+ ME_CONFIG_MONGODB_SERVER : db
23
+ networks :
24
+ - db_network # for db
25
+ - web_network # for interface
26
+ depends_on :
27
+ - db
28
+
29
+ backend :
30
+ build : ./backend
31
+ command : --log-level debug
32
+ restart : always
33
+ volumes :
34
+ - ./backend:/app
35
+ environment :
36
+ PORT : 5000
37
+ DEBUG : $DEBUG
38
+ SECRET_KEY : $SECRET_KEY
39
+ DATABASE_URL : $DATABASE_URL
40
+ depends_on :
41
+ - db
42
+ networks :
43
+ - db_network
44
+ - web_network
45
+
46
+ frontend :
47
+ build :
48
+ context : ./frontend
49
+ args :
50
+ DEBUG : $DEBUG
51
+ NODE_ENV : $NODE_ENV
52
+ entrypoint : ./entrypoint.sh
53
+ restart : unless-stopped
54
+ volumes :
55
+ - web-root:/home/node/app/dist
56
+ - ./frontend:/home/node/app
57
+ - /home/node/app/node_modules
58
+ environment :
59
+ NODE_ENV : $NODE_ENV
60
+ PORT : 8080
61
+ DEBUG : $DEBUG
62
+ depends_on :
63
+ - backend
64
+ networks :
65
+ - web_network
66
+
67
+ nginx :
68
+ image : nginx:latest
69
+ ports :
70
+ - 8000:80
71
+ volumes :
72
+ - web-root:/var/www/html
73
+ - ./config/nginx:/etc/nginx/conf.d/
74
+ depends_on :
75
+ - frontend
76
+ - backend
77
+ - db_interface
78
+ networks :
79
+ - web_network
80
+
81
+ networks :
82
+ web_network :
83
+ driver : bridge
84
+ db_network :
85
+ driver : bridge
86
+
87
+ volumes :
88
+ web-root :
89
+ db_vol :
Original file line number Diff line number Diff line change
1
+ COMPOSE_PROJECT_NAME='fastapi-template'
2
+ DB_USERNAME=root
3
+ DB_PASSWORD=password
4
+ MONGO_INITDB_DATABASE=core
5
+ DATABASE_URL=mongodb://root:password@db:27017
6
+ NODE_ENV=development
7
+ DEBUG=1
8
+ SECRET_KEY="change-this-key"
You can’t perform that action at this time.
0 commit comments