From 5cecff95a721720ef8f602bd53733869957c5a27 Mon Sep 17 00:00:00 2001 From: Heitor Neiva Date: Tue, 30 Jul 2024 15:16:34 -0700 Subject: [PATCH] Add vscode dev container configuration This enables us to run vscode inside a container[1] Running it inside a container allows the db and softhsm tests to run Debugging tests (with breakpoints) in vscode should also be possible when running it inside a container! [1] https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers --- .devcontainer/devcontainer.json | 26 +++++++++++++++++++++ .devcontainer/docker-compose.yml | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..dfc68ebb3 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,26 @@ +// NOTE: YOU MUST RUN docker compose build app && docker compose build BEFORE ATTEMPTING TO RUN DEV CONTAINERS + +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile +{ + "name": "app-hsm autograph" + ,"dockerComposeFile": "docker-compose.yml" + ,"service": "app-hsm" + ,"containerUser": "app" + // ,"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind" + ,"workspaceFolder": "/workspace" + + // Features to add to the dev container. More info: https://containers.dev/features. + ,"features": { + "ghcr.io/devcontainers/features/go:1": { + "version": "1.22", + "golangciLintVersion": "1.59.1" + }, + "ghcr.io/devcontainers/features/git:1": {} + } + // Ensure the container is alive and running + ,"overrideCommand": true + + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + ,"remoteUser": "root" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 000000000..f61a805eb --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,40 @@ +volumes: + apptmpdir: + hsmtmpdir: +services: + db: + extends: + service: db + file: ../docker-compose.yml + app: + extends: + service: app + file: ../docker-compose.yml + volumes: + - apptmpdir:/tmp/ + - ../:/workspace + app-hsm: + extends: + service: app-hsm + file: ../docker-compose.yml + volumes: + - hsmtmpdir:/tmp/ + - ../:/workspace + # We don't really need these for dev work + # but will keep these commented out just in case + # monitor: + # extends: + # service: monitor + # file: ../docker-compose.yml + # monitor-lambda-emulator: + # extends: + # service: monitor-lambda-emulator + # file: ../docker-compose.yml + # monitor-hsm-lambda-emulator: + # extends: + # service: monitor-hsm-lambda-emulator + # file: ../docker-compose.yml + # unit-test: + # extends: + # service: unit-test + # file: ../docker-compose.yml