From 54ecb2ee8c8c864419588c1329bd1f47e4feee87 Mon Sep 17 00:00:00 2001 From: Ittipat Lusuk Date: Tue, 12 May 2026 19:10:04 +0700 Subject: [PATCH] [image-service] updated ALLOWED_FOLDERS --- docker-compose.yml | 19 +++++++++++++++++-- main.py | 14 ++++++++++++-- nginx.conf | 10 ++++++---- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 44ae71e..8d5a664 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,16 +9,31 @@ services: environment: - PYTHONUNBUFFERED=1 volumes: - - ~/repo/taobin_project:/taobin_project + - shared-repo:/usr/src/app + # - ~/repo/taobin_project:/taobin_project restart: always command: uvicorn main:app --host 0.0.0.0 --port 8125 + networks: + - kong-net nginx: image: nginx:latest container_name: nginx-image-container volumes: - - ~/repo/taobin_project:/taobin_project + - shared-repo:/usr/src/app + # - ~/repo/taobin_project:/taobin_project - ./nginx.conf:/etc/nginx/conf.d/default.conf ports: - "8126:80" + networks: + - kong-net + +networks: + kong-net: + external: true + name: kong-api-gateway_kong-ee-net + +volumes: + shared-repo: + external: true \ No newline at end of file diff --git a/main.py b/main.py index 046ff18..1f83bec 100644 --- a/main.py +++ b/main.py @@ -7,9 +7,19 @@ import uuid app = FastAPI() -BASE_DIR = Path("/taobin_project") +BASE_DIR = Path("/usr/src/app/taobin_project") +# BASE_DIR = Path("/taobin_project") + +ALLOWED_FOLDERS = {"page_drink", +"page_drink_disable", +"page_drink_disable_n", +"page_drink_disable_n2", +"page_drink_n", +"page_drink_picture2_n", +"page_drink_press", +"page_drink_press_n", +"page_drink_select"} -ALLOWED_FOLDERS = {"page_drink_n", "page_drink_press_n", "page_drink_disable_n2"} ALLOWED_EXTENSIONS = {".jpg", ".jpeg", ".png", ".gif", ".webp"} def validate_folder(folder: str): diff --git a/nginx.conf b/nginx.conf index e70f71c..2ff2da8 100644 --- a/nginx.conf +++ b/nginx.conf @@ -2,13 +2,15 @@ server { listen 80; # /image/{folder}/... - location ~ ^/image/(page_drink_n|page_drink_press_n|page_drink_disable_n2)/(.*)$ { - alias /taobin_project/image/$1/$2; + location ~ ^/image/(page_drink|page_drink_disable|page_drink_disable_n|page_drink_disable_n2|page_drink_n|page_drink_picture2_n|page_drink_press|page_drink_press_n|page_drink_select)/(.*)$ { + alias /usr/src/app/taobin_project/image/$1/$2; + # alias /taobin_project/image/$1/$2; } # /inter/{country}/image/{folder}/... - location ~ ^/inter/([^/]+)/image/(page_drink_n|page_drink_press_n|page_drink_disable_n2)/(.*)$ { - alias /taobin_project/inter/$1/image/$2/$3; + location ~ ^/inter/([^/]+)/image/(page_drink|page_drink_disable|page_drink_disable_n|page_drink_disable_n2|page_drink_n|page_drink_picture2_n|page_drink_press|page_drink_press_n|page_drink_select)/(.*)$ { + alias /usr/src/app/taobin_project/inter/$1/image/$2/$3; + # alias /taobin_project/inter/$1/image/$2/$3; } # Block any path