From 1fbd6628e3da9e29b160d2831b7465f904ade9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= <33655937+jkoenig134@users.noreply.github.com> Date: Mon, 9 Oct 2023 16:23:49 +0200 Subject: [PATCH] VSCode debugging support (#278) * chore: add recommended extensions * chore: add launch config for attaching * chore: update entrypoint for Dockerfile.debug * chore: switch to pgsql for local development * chore: add task for docker compose up * chore: rename launch configuration * chore: move pg-admin dependency to postgres * chore: remove unused reference * fix: exclude obj and bin folders in mounting * chore: make "start" task always build the compose stack * chore: use postgres for local development --------- Co-authored-by: tnotheis Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .vscode/extensions.json | 3 + .vscode/launch.json | 16 +++++ .vscode/tasks.json | 10 +++ ConsumerApi/Dockerfile.debug | 2 +- ConsumerApi/appsettings.override.json | 48 +++++++------- .../Devices.Infrastructure.Tests.csproj | 1 - docker-compose/docker-compose.yml | 66 ++++++++++--------- 7 files changed, 89 insertions(+), 57 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000000..8c332ef07a --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["ms-azuretools.vscode-docker", "ms-dotnettools.csdevkit"] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..6e15e53a3f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to Consumer API (Docker)", + "type": "docker", + "request": "attach", + "platform": "netCore", + "sourceFileMap": { + "/app": "${workspaceFolder}" + }, + "containerName": "consumerApi", + "processName": "ConsumerApi" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000..4b75e0d036 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,10 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "start", + "command": "docker", + "args": ["compose", "-f", "docker-compose/docker-compose.yml", "up", "--build", "--attach", "consumerApi"] + } + ] +} diff --git a/ConsumerApi/Dockerfile.debug b/ConsumerApi/Dockerfile.debug index 9597ec5524..de0bf131c1 100644 --- a/ConsumerApi/Dockerfile.debug +++ b/ConsumerApi/Dockerfile.debug @@ -3,4 +3,4 @@ EXPOSE 80 WORKDIR /app -ENTRYPOINT ["dotnet", "run", "--project", "ConsumerApi/ConsumerApi.csproj"] +ENTRYPOINT ["dotnet", "watch", "--non-interactive", "--project", "ConsumerApi/ConsumerApi.csproj"] diff --git a/ConsumerApi/appsettings.override.json b/ConsumerApi/appsettings.override.json index d3f057b4d8..aab3d7a47a 100644 --- a/ConsumerApi/appsettings.override.json +++ b/ConsumerApi/appsettings.override.json @@ -28,27 +28,27 @@ "Challenges": { "Infrastructure": { "SqlDatabase": { - "Provider": "SqlServer", - "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=challenges;Password=Passw0rd;TrustServerCertificate=True" - //"ConnectionString": "User ID=challenges;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + "Provider": "Postgres", + "ConnectionString": "User ID=challenges;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=challenges;Password=Passw0rd;TrustServerCertificate=True" // sqlserver } } }, "Quotas": { "Infrastructure": { "SqlDatabase": { - "Provider": "SqlServer", - "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=quotas;Password=Passw0rd;TrustServerCertificate=True" - //"ConnectionString": "User ID=quotas;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + "Provider": "Postgres", + "ConnectionString": "User ID=quotas;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=quotas;Password=Passw0rd;TrustServerCertificate=True" // sqlserver } } }, "Devices": { "Infrastructure": { "SqlDatabase": { - "Provider": "SqlServer", - "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=devices;Password=Passw0rd;TrustServerCertificate=True" - //"ConnectionString": "User ID=devices;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + "Provider": "Postgres", + "ConnectionString": "User ID=devices;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=devices;Password=Passw0rd;TrustServerCertificate=True" // sqlserver }, "PushNotifications": { "Provider": "Dummy" @@ -58,9 +58,9 @@ "Files": { "Infrastructure": { "SqlDatabase": { - "Provider": "SqlServer", - "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=files;Password=Passw0rd;TrustServerCertificate=True" - //"ConnectionString": "User ID=files;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + "Provider": "Postgres", + "ConnectionString": "User ID=files;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=files;Password=Passw0rd;TrustServerCertificate=True" // sqlserver }, "BlobStorage": { "CloudProvider": "Azure", @@ -72,9 +72,9 @@ "Messages": { "Infrastructure": { "SqlDatabase": { - "Provider": "SqlServer", - "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=messages;Password=Passw0rd;TrustServerCertificate=True" - //"ConnectionString": "User ID=messages;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + "Provider": "Postgres", + "ConnectionString": "User ID=messages;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=messages;Password=Passw0rd;TrustServerCertificate=True" // sqlserver }, "BlobStorage": { "CloudProvider": "Azure", @@ -86,9 +86,9 @@ "Relationships": { "Infrastructure": { "SqlDatabase": { - "Provider": "SqlServer", - "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=relationships;Password=Passw0rd;TrustServerCertificate=True" - //"ConnectionString": "User ID=relationships;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + "Provider": "Postgres", + "ConnectionString": "User ID=relationships;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=relationships;Password=Passw0rd;TrustServerCertificate=True" // sqlserver }, "BlobStorage": { "CloudProvider": "Azure", @@ -100,9 +100,9 @@ "Synchronization": { "Infrastructure": { "SqlDatabase": { - "Provider": "SqlServer", - "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=synchronization;Password=Passw0rd;TrustServerCertificate=True" - //"ConnectionString": "User ID=synchronization;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + "Provider": "Postgres", + "ConnectionString": "User ID=synchronization;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=synchronization;Password=Passw0rd;TrustServerCertificate=True" // sqlserver }, "BlobStorage": { "CloudProvider": "Azure", @@ -114,9 +114,9 @@ "Tokens": { "Infrastructure": { "SqlDatabase": { - "Provider": "SqlServer", - "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=tokens;Password=Passw0rd;TrustServerCertificate=True" - //"ConnectionString": "User ID=tokens;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + "Provider": "Postgres", + "ConnectionString": "User ID=tokens;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=tokens;Password=Passw0rd;TrustServerCertificate=True" // sqlserver }, "BlobStorage": { "CloudProvider": "Azure", diff --git a/Modules/Devices/test/Devices.Infrastructure.Tests/Devices.Infrastructure.Tests.csproj b/Modules/Devices/test/Devices.Infrastructure.Tests/Devices.Infrastructure.Tests.csproj index e2fd882d70..c6c6492bbc 100644 --- a/Modules/Devices/test/Devices.Infrastructure.Tests/Devices.Infrastructure.Tests.csproj +++ b/Modules/Devices/test/Devices.Infrastructure.Tests/Devices.Infrastructure.Tests.csproj @@ -12,7 +12,6 @@ - diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 98b5c3197f..01b903eb37 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -21,14 +21,16 @@ services: - Modules__Tokens__Infrastructure__BlobStorage__ConnectionInfo=${ENMESHED_BLOB_STORAGE_CONNECTION_STRING} # set this environment variable on your local system to an appropriate value (DefaultEndpointsProtocol=https;AccountName=;AccountKey=;EndpointSuffix=core.windows.net) ports: - - "127.0.0.10:80:80" - - "5000:80" + - "8080:80" depends_on: - - ms-sql-server + # - ms-sql-server - rabbitmq - azure-storage-emulator + - postgres volumes: - ../:/app + - /app/ConsumerApi/obj + - /app/ConsumerApi/bin ### infrastructure ### @@ -42,38 +44,40 @@ services: volumes: - azure-storage-emulator-volume:/data - ms-sql-server: - container_name: bkb-mssql_server - hostname: ms-sql-server - image: mcr.microsoft.com/mssql/server:2019-latest + # ms-sql-server: + # container_name: bkb-mssql_server + # hostname: ms-sql-server + # image: mcr.microsoft.com/mssql/server:2019-latest + # environment: + # - MSSQL_SA_PASSWORD=Passw0rd + # - ACCEPT_EULA=Y + # - MSSQL_PID=Express + # volumes: + # - mssql-server-volume:/var/opt/mssql + # ports: + # - 1433:1433 + + postgres: + container_name: bkb-postgres + hostname: postgres + image: postgres environment: - - MSSQL_SA_PASSWORD=Passw0rd - - ACCEPT_EULA=Y - - MSSQL_PID=Express + - POSTGRES_PASSWORD=admin volumes: - - mssql-server-volume:/var/opt/mssql + - postgres-volume:/var/lib/postgresql/data ports: - - 1433:1433 - - #postgres: - # container_name: bkb-postgres - # hostname: postgres - # image: postgres - # environment: - # - POSTGRES_PASSWORD=admin - # volumes: - # - postgres-volume:/var/lib/postgresql/data - # ports: - # - 5432:5432 + - 5432:5432 + depends_on: + - pg-admin - #pg-admin: - # container_name: bkb-pgadmin - # image: dpage/pgadmin4 - # ports: - # - 85:80 - # environment: - # - PGADMIN_DEFAULT_PASSWORD=admin - # - PGADMIN_DEFAULT_EMAIL=admin@enmeshed.eu + pg-admin: + container_name: bkb-pgadmin + image: dpage/pgadmin4 + ports: + - 85:80 + environment: + - PGADMIN_DEFAULT_PASSWORD=admin + - PGADMIN_DEFAULT_EMAIL=admin@enmeshed.eu rabbitmq: container_name: bkb-rabbitmq