From 4ac14545f35a9dac0e5f973af6f83583b5db69ba Mon Sep 17 00:00:00 2001 From: soliujing Date: Thu, 22 May 2025 11:30:17 +0800 Subject: [PATCH] out-of-box for debug at local --- .vscode/launch.json | 23 +++++++++++++++-------- docker-compose-db.yml | 30 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 docker-compose-db.yml diff --git a/.vscode/launch.json b/.vscode/launch.json index 24eae850d0..ec095f3de8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,24 +5,31 @@ "version": "0.2.0", "configurations": [ { - "name": "Debug FastAPI Project backend: Python Debugger", + "type": "node", + "request": "launch", + "name": "Debug frontend - React: npm run dev", + "runtimeExecutable": "npm", + "runtimeArgs": ["run", "dev"], + "console": "integratedTerminal", + "cwd": "${workspaceFolder}/frontend", + "envFile": "${workspaceFolder}/.env" + }, + { + "name": "Debug backend - Fastapi: debugpy", "type": "debugpy", "request": "launch", "module": "uvicorn", - "args": [ - "app.main:app", - "--reload" - ], + "args": ["app.main:app", "--reload"], "cwd": "${workspaceFolder}/backend", "jinja": true, - "envFile": "${workspaceFolder}/.env", + "envFile": "${workspaceFolder}/.env" }, { "type": "chrome", "request": "launch", - "name": "Debug Frontend: Launch Chrome against http://localhost:5173", + "name": "Debug Frontend: Launch Chrome http://localhost:5173", "url": "http://localhost:5173", "webRoot": "${workspaceFolder}/frontend" - }, + } ] } diff --git a/docker-compose-db.yml b/docker-compose-db.yml new file mode 100644 index 0000000000..e9ca56406c --- /dev/null +++ b/docker-compose-db.yml @@ -0,0 +1,30 @@ +services: + + db: + image: postgres:17 + restart: always + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] + interval: 10s + retries: 5 + start_period: 30s + timeout: 10s + ports: + - "127.0.0.1:5432:5432" + volumes: + - app-db-data:/var/lib/postgresql/data/pgdata + env_file: + - .env + environment: + - PGDATA=/var/lib/postgresql/data/pgdata + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set} + - POSTGRES_USER=${POSTGRES_USER?Variable not set} + - POSTGRES_DB=${POSTGRES_DB?Variable not set} + +volumes: + app-db-data: + +# networks: +# traefik-public: +# # Allow setting it to false for testing +# external: true