1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-07 14:25:37 +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

@ -26,4 +26,5 @@ pytest-split==0.6.0
bandit==1.7.2
pip-tools==6.5.1
autopep8==1.5.7
pytest-unordered==0.4.1
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
@ -136,15 +140,15 @@ services:
mailhog:
image: mailhog/mailhog
logging:
driver: 'none' # disable saving logs
driver: 'none' # disable saving logs
ports:
- "8025:8025" # web ui
networks:
local:
# When switching between dev and local the media files in the media volume will be
# owned by different users. Ensure that we chown them to the user appropriate for the
# environment here.
# When switching between dev and local the media files in the media volume will be
# owned by different users. Ensure that we chown them to the user appropriate for the
# environment here.
volume-permissions-fixer:
image: bash:4.4
command: chown ${UID:-1000}:${GID:-1000} -R /baserow/media

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: [