1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-14 09:08:32 +00:00

Improve debugging for frontend and backend

This commit is contained in:
Davide Silvestri 2022-04-13 07:56:43 +00:00
parent 11a7251cff
commit ccabf86685
5 changed files with 37 additions and 5 deletions
backend
requirements
src/baserow
docker-compose.dev.yml
web-frontend/config

View file

@ -27,3 +27,4 @@ bandit==1.7.2
pip-tools==6.5.1
autopep8==1.5.7
pytest-unordered==0.4.1
debugpy==1.5.1

View file

@ -44,6 +44,8 @@ click==8.0.4
# pip-tools
coverage==6.2
# via -r dev.in
debugpy==1.5.1
# via -r dev.in
django==3.2.12
# via
# -c base.txt

View file

@ -1,8 +1,30 @@
#!/usr/bin/env python
import os
import sys
def enable_debugger():
"""Enable the debugger if the environment variable is set."""
debugger_enabled = bool(os.environ.get("BASEROW_BACKEND_DEBUGGER_ENABLED"))
if debugger_enabled:
import debugpy
debugger_port = int(os.environ.get("BASEROW_BACKEND_DEBUGGER_PORT", 5678))
debugpy.listen(("0.0.0.0", debugger_port)) # nosec
print(f"Debugger attached! Listening on 0.0.0.0:{debugger_port}")
else:
print(
"Debugger disabled. Set the env variable "
"BASEROW_BACKEND_DEBUGGER_ENABLED=True to enable it."
)
def main():
from django.conf import settings
if settings.DEBUG and os.environ.get("RUN_MAIN"):
enable_debugger()
try:
from django.core.management import execute_from_command_line
except ImportError as exc:

View file

@ -15,6 +15,9 @@ services:
backend:
image: baserow_backend_dev:latest
environment:
- BASEROW_BACKEND_DEBUGGER_ENABLED=${BASEROW_BACKEND_DEBUGGER_ENABLED:-True}
- BASEROW_BACKEND_DEBUGGER_PORT=${BASEROW_BACKEND_DEBUGGER_PORT:-5678}
build:
dockerfile: ./backend/Dockerfile
context: .
@ -26,6 +29,7 @@ services:
GID: $GID
ports:
- "${HOST_PUBLISH_IP:-127.0.0.1}:8000:8000"
- "${HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_BACKEND_DEBUGGER_PORT:-5678}:${BASEROW_BACKEND_DEBUGGER_PORT:-5678}"
volumes:
- ./backend:/baserow/backend
- ./premium/backend/:/baserow/premium/backend

View file

@ -15,6 +15,9 @@ export default Object.assign(base(), {
build: {
extend(config, ctx) {
config.node = { fs: 'empty' }
if (ctx.isDev) {
config.devtool = ctx.isClient ? 'source-map' : 'inline-source-map'
}
},
babel: { compact: true },
plugins: [