From 332d4f723b22bdb8a600f532b1c43ab9b62e8a8b Mon Sep 17 00:00:00 2001 From: NKSL2001 Date: Thu, 24 Oct 2024 10:58:57 +0800 Subject: [PATCH 1/6] setup frontend in docker --- docker-compose.yaml | 51 ++++++++++++++++++++--------------------- nginx/conf.d/local.conf | 2 +- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 912de88..ece53e1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -22,6 +22,16 @@ services: - default.env networks: - db_network + environment: + POSTGRES_PASSWORD: password + adminer: + image: adminer + restart: always + ports: + - 8080:8080 + networks: + - db_network + redis: image: redis:2.8 command: redis-server @@ -32,7 +42,6 @@ services: web: build: context: ./deans-api - image: django_image entrypoint: "start_django.sh" env_file: - default.env @@ -51,7 +60,6 @@ services: notification: build: context: ./deans-notification - image: notification_image entrypoint: "start_server.sh" # command: "python -c \"while True: pass\"" # ports: @@ -62,14 +70,20 @@ services: - ./deans-notification:/work networks: - notification_network - # frontend: - # build: - # context: ./deans-frontend - # image: frontend_image - # networks: - # - frontend_network - # ports: - # - 3000:3000 + + frontend: + build: ./deans-frontend + ports: + - "3000:3000" + expose: + - 3000 + volumes: + - ./deans-frontend:/work/ + command: bash -c "yarn install; yarn start" + networks: + # - frontend_network + - nginx_network + nginx: build: context: ./nginx @@ -88,7 +102,7 @@ services: networks: - nginx_network cron: - image: django_image + image: python:3.6 command: bash -c "python3 /cron/cron.py" env_file: - default.env @@ -105,18 +119,3 @@ volumes: static_volume: - - - # node: - # build: ./deans-frontend - # ports: - # - "3000:3000" - # expose: - # - 3000 - # volumes: - # - ./deans-frontend:/work/ - # ports: - # - "3000" - # command: bash -c "yarn install; yarn start" - # networks: - # - nginx_network \ No newline at end of file diff --git a/nginx/conf.d/local.conf b/nginx/conf.d/local.conf index bca87ea..3e9e434 100644 --- a/nginx/conf.d/local.conf +++ b/nginx/conf.d/local.conf @@ -15,7 +15,7 @@ server { server_name localhost; location /api/ { - proxy_pass http://api_server; + proxy_pass http://web:8000; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; From d3507265418778ae70ba3034f5253e6a3627b73a Mon Sep 17 00:00:00 2001 From: NKSL2001 Date: Thu, 24 Oct 2024 11:00:33 +0800 Subject: [PATCH 2/6] update submodule pointer --- .gitmodules | 6 +++--- deans-api | 2 +- deans-frontend | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitmodules b/.gitmodules index ad695c4..616e515 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ [submodule "deans-api"] path = deans-api - url = https://github.com/Deans-CMS/deans-api + url = https://github.com/NKSL2001/deans-api.git [submodule "deans-frontend"] path = deans-frontend - url = https://github.com/Deans-CMS/deans-frontend + url = https://github.com/NKSL2001/deans-frontend.git [submodule "deans-notification"] path = deans-notification - url = https://github.com/Deans-CMS/deans-notification.git + url = https://github.com/NKSL2001/deans-notification.git diff --git a/deans-api b/deans-api index dbfa6b6..ba37fd5 160000 --- a/deans-api +++ b/deans-api @@ -1 +1 @@ -Subproject commit dbfa6b63ddb5b8d401dbd2fa7319d6d22e895d8a +Subproject commit ba37fd5609d560104a5562ad20c870c31b3b550d diff --git a/deans-frontend b/deans-frontend index ed6cad5..4e42e4c 160000 --- a/deans-frontend +++ b/deans-frontend @@ -1 +1 @@ -Subproject commit ed6cad5cd8fcc2ad1bd74b4a7202d495977cc4ae +Subproject commit 4e42e4c4f757f2ed964667385a352b4fa056c3ca From e32072024c60b4265b041ccadd81b2b2598e7536 Mon Sep 17 00:00:00 2001 From: NKSL2001 Date: Thu, 24 Oct 2024 11:21:09 +0800 Subject: [PATCH 3/6] add persistent db --- docker-compose.yaml | 54 +++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index ece53e1..5c3c998 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -22,6 +22,8 @@ services: - default.env networks: - db_network + volumes: + - ./tidb:/var/lib/postgresql/data environment: POSTGRES_PASSWORD: password adminer: @@ -57,19 +59,19 @@ services: - nginx_network - notification_network - redis_network - notification: - build: - context: ./deans-notification - entrypoint: "start_server.sh" - # command: "python -c \"while True: pass\"" - # ports: - # - "8000:3000" - env_file: - - default.env - volumes: - - ./deans-notification:/work - networks: - - notification_network +# notification: +# build: +# context: ./deans-notification +# entrypoint: "start_server.sh" +# # command: "python -c \"while True: pass\"" +# # ports: +# # - "8000:3000" +# env_file: +# - default.env +# volumes: +# - ./deans-notification:/work +# networks: +# - notification_network frontend: build: ./deans-frontend @@ -101,19 +103,19 @@ services: # - node networks: - nginx_network - cron: - image: python:3.6 - command: bash -c "python3 /cron/cron.py" - env_file: - - default.env - volumes: - - ./cron:/cron - - ./deans-api/deans_api:/work/deans-api/deans_api - depends_on: - - web - networks: - - notification_network - - db_network +# cron: +# image: python:3.6 +# command: bash -c "python3 /cron/cron.py" +# env_file: +# - default.env +# volumes: +# - ./cron:/cron +# - ./deans-api/deans_api:/work/deans-api/deans_api +# depends_on: +# - web +# networks: +# - notification_network +# - db_network volumes: static_volume: From fa612f7159c339b6546786afdd53ae4fbb9aa2b9 Mon Sep 17 00:00:00 2001 From: NKSL2001 Date: Fri, 15 Nov 2024 00:08:52 +0800 Subject: [PATCH 4/6] update pointer for pr assignment --- deans-api | 2 +- deans-frontend | 2 +- deans-notification | 2 +- docker-compose.yaml | 225 ++++++++++++++++++++++---------------------- 4 files changed, 114 insertions(+), 117 deletions(-) diff --git a/deans-api b/deans-api index ba37fd5..ec31f61 160000 --- a/deans-api +++ b/deans-api @@ -1 +1 @@ -Subproject commit ba37fd5609d560104a5562ad20c870c31b3b550d +Subproject commit ec31f61ce64c2ddf3a1b20fdd0823d738555fabd diff --git a/deans-frontend b/deans-frontend index 4e42e4c..de1ea5e 160000 --- a/deans-frontend +++ b/deans-frontend @@ -1 +1 @@ -Subproject commit 4e42e4c4f757f2ed964667385a352b4fa056c3ca +Subproject commit de1ea5e91955d5c62a7461e9fb49f99b29746f26 diff --git a/deans-notification b/deans-notification index 5df90db..fe8ce9a 160000 --- a/deans-notification +++ b/deans-notification @@ -1 +1 @@ -Subproject commit 5df90db4b2c5500b6aaae1682e684c8e18a773e7 +Subproject commit fe8ce9aa51f42d5b13e80e571eb13942d96ca02b diff --git a/docker-compose.yaml b/docker-compose.yaml index 5c3c998..11dfc3c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,123 +1,120 @@ -version: '3' +version: "3" networks: - nginx_network: - driver: bridge - db_network: - driver: bridge - notification_network: - driver: bridge - redis_network: - driver: bridge - # frontend_network: - # driver: bridge - + nginx_network: + driver: bridge + db_network: + driver: bridge + notification_network: + driver: bridge + redis_network: + driver: bridge + # frontend_network: + # driver: bridge services: - db: - image: postgres - ports: - - "5432:5432" - env_file: - - default.env - networks: - - db_network - volumes: - - ./tidb:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: password - adminer: - image: adminer - restart: always - ports: - - 8080:8080 - networks: - - db_network + db: + image: postgres + ports: + - "5432:5432" + env_file: + - default.env + networks: + - db_network + volumes: + - ./tidb:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: password + adminer: + image: adminer + restart: always + ports: + - 8080:8080 + networks: + - db_network - redis: - image: redis:2.8 - command: redis-server - ports: - - "6379:6379" - networks: - - redis_network - web: - build: - context: ./deans-api - entrypoint: "start_django.sh" - env_file: - - default.env - volumes: - - ./deans-api/data:/data - - ./deans-api/deans_api:/work/deans-api/deans_api - - static_volume:/static-django - depends_on: - - db - - redis - networks: - - db_network - - nginx_network - - notification_network - - redis_network -# notification: -# build: -# context: ./deans-notification -# entrypoint: "start_server.sh" -# # command: "python -c \"while True: pass\"" -# # ports: -# # - "8000:3000" -# env_file: -# - default.env -# volumes: -# - ./deans-notification:/work -# networks: -# - notification_network + redis: + image: redis:2.8 + command: redis-server + ports: + - "6379:6379" + networks: + - redis_network + web: + build: + context: ./deans-api + entrypoint: "start_django.sh" + env_file: + - default.env + volumes: + - ./deans-api/data:/data + - ./deans-api/deans_api:/work/deans-api/deans_api + - static_volume:/static-django + depends_on: + - db + # - redis + networks: + - db_network + - nginx_network + - notification_network + - redis_network + # notification: + # build: + # context: ./deans-notification + # entrypoint: "start_server.sh" + # # command: "python -c \"while True: pass\"" + # # ports: + # # - "8000:3000" + # env_file: + # - default.env + # volumes: + # - ./deans-notification:/work + # networks: + # - notification_network - frontend: - build: ./deans-frontend - ports: - - "3000:3000" - expose: - - 3000 - volumes: - - ./deans-frontend:/work/ - command: bash -c "yarn install; yarn start" - networks: - # - frontend_network - - nginx_network + frontend: + build: ./deans-frontend + ports: + - "3000:3000" + expose: + - 3000 + volumes: + - ./deans-frontend:/work/ + command: bash -c "yarn install; yarn start" + networks: + # - frontend_network + - nginx_network - nginx: - build: - context: ./nginx - image: nginx:1.13 - ports: - - 8000:80 - volumes: - - ./nginx/conf.d:/etc/nginx/conf.d - - static_volume:/static-django - env_file: - - default.env - depends_on: - - web - # - frontend - # - node - networks: - - nginx_network -# cron: -# image: python:3.6 -# command: bash -c "python3 /cron/cron.py" -# env_file: -# - default.env -# volumes: -# - ./cron:/cron -# - ./deans-api/deans_api:/work/deans-api/deans_api -# depends_on: -# - web -# networks: -# - notification_network -# - db_network + nginx: + build: + context: ./nginx + image: nginx:1.13 + ports: + - 8000:80 + volumes: + - ./nginx/conf.d:/etc/nginx/conf.d + - static_volume:/static-django + env_file: + - default.env + depends_on: + - web + # - frontend + # - node + networks: + - nginx_network + # cron: + # image: python:3.6 + # command: bash -c "python3 /cron/cron.py" + # env_file: + # - default.env + # volumes: + # - ./cron:/cron + # - ./deans-api/deans_api:/work/deans-api/deans_api + # depends_on: + # - web + # networks: + # - notification_network + # - db_network volumes: - static_volume: - - + static_volume: From 17da3d674e72853cdb37da0b6da11b9475eaeded Mon Sep 17 00:00:00 2001 From: NKSL2001 Date: Fri, 15 Nov 2024 12:42:23 +0800 Subject: [PATCH 5/6] update database setup and pointer to api --- deans-api | 2 +- docker-compose.yaml | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/deans-api b/deans-api index ec31f61..8bd7a90 160000 --- a/deans-api +++ b/deans-api @@ -1 +1 @@ -Subproject commit ec31f61ce64c2ddf3a1b20fdd0823d738555fabd +Subproject commit 8bd7a90fe6a76ee1bbb5ec9cfecf147f902bc44f diff --git a/docker-compose.yaml b/docker-compose.yaml index 11dfc3c..1134174 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -14,7 +14,7 @@ networks: services: db: - image: postgres + image: postgres:17 ports: - "5432:5432" env_file: @@ -22,7 +22,7 @@ services: networks: - db_network volumes: - - ./tidb:/var/lib/postgresql/data + - database_volume:/var/lib/postgresql/data environment: POSTGRES_PASSWORD: password adminer: @@ -118,3 +118,4 @@ services: volumes: static_volume: + database_volume: From ec6389bc50ff802d5dd4743b4b42530cb41d324e Mon Sep 17 00:00:00 2001 From: Nahian12 Date: Sun, 17 Nov 2024 21:08:40 +0800 Subject: [PATCH 6/6] Refactor Code (Backend-Web) --- deans-api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deans-api b/deans-api index 8bd7a90..acd993f 160000 --- a/deans-api +++ b/deans-api @@ -1 +1 @@ -Subproject commit 8bd7a90fe6a76ee1bbb5ec9cfecf147f902bc44f +Subproject commit acd993ff25ed1959dd9ef7612d4d5686d008185e