From eec6424bc945270ccf86850ffcb31e59ac2cd3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Michaud?= Date: Mon, 1 Jun 2020 08:50:55 +0200 Subject: [PATCH] [DEV] Debug authelia when running a suite. (#1060) * [DEV] Debug authelia when running a suite. This runs dlv debugger within authelia backend container so that an IDE can remote debug the application using port 2345. * Apply suggestions from code review Co-authored-by: Amir Zarrinkafsh --- .gitignore | 4 +++- .../example/compose/authelia/docker-compose.backend.dev.yml | 5 +++++ .../compose/authelia/resources/entrypoint-backend.sh | 6 ++++++ .../example/compose/authelia/resources/run-backend-dev.sh | 4 +--- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6414e17c9..b7ca861c5 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,6 @@ Configuration.schema.json qemu-*-static -public_html.gen.go \ No newline at end of file +public_html.gen.go + +__debug_bin diff --git a/internal/suites/example/compose/authelia/docker-compose.backend.dev.yml b/internal/suites/example/compose/authelia/docker-compose.backend.dev.yml index 10316235f..e1e36700f 100644 --- a/internal/suites/example/compose/authelia/docker-compose.backend.dev.yml +++ b/internal/suites/example/compose/authelia/docker-compose.backend.dev.yml @@ -7,8 +7,13 @@ services: args: USER_ID: ${USER_ID} GROUP_ID: ${GROUP_ID} + security_opt: + - seccomp:unconfined + - apparmor:unconfined command: /resources/entrypoint-backend.sh working_dir: /app + cap_add: + - SYS_PTRACE volumes: - './example/compose/authelia/resources/:/resources' - '../..:/app' diff --git a/internal/suites/example/compose/authelia/resources/entrypoint-backend.sh b/internal/suites/example/compose/authelia/resources/entrypoint-backend.sh index f6290ea38..6446f8d21 100755 --- a/internal/suites/example/compose/authelia/resources/entrypoint-backend.sh +++ b/internal/suites/example/compose/authelia/resources/entrypoint-backend.sh @@ -2,8 +2,14 @@ set -x +# We move out of the workspace to not include the modules as dependencies of the project. +cd / + echo "Use hot reloaded version of Authelia backend" go get github.com/cespare/reflex +go get github.com/go-delve/delve/cmd/dlv + +cd /app # Sleep 10 seconds to wait the end of npm install updating web directory # and making reflex reload multiple times. diff --git a/internal/suites/example/compose/authelia/resources/run-backend-dev.sh b/internal/suites/example/compose/authelia/resources/run-backend-dev.sh index a809cf089..67fb450df 100755 --- a/internal/suites/example/compose/authelia/resources/run-backend-dev.sh +++ b/internal/suites/example/compose/authelia/resources/run-backend-dev.sh @@ -2,10 +2,8 @@ set -e -# Build the binary -go build -o /tmp/authelia/authelia-tmp cmd/authelia/*.go while true; do - /tmp/authelia/authelia-tmp --config /etc/authelia/configuration.yml + dlv --listen 0.0.0.0:2345 --headless=true --continue --accept-multiclient debug cmd/authelia/*.go -- --config /etc/authelia/configuration.yml sleep 10 done \ No newline at end of file