From 6bea5138e59f6ada147c4898bd0e97cc3b9136df Mon Sep 17 00:00:00 2001 From: Uragami Taichi Date: Sat, 16 Aug 2025 15:29:08 +0900 Subject: [PATCH 1/6] Add devcontainer configuration --- .devcontainer/Dockerfile | 4 ++++ .devcontainer/devcontainer.json | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..a5347d3 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,4 @@ +FROM mcr.microsoft.com/devcontainers/java:1-17-bullseye + +RUN mkdir /home/vscode/.m2 && \ + chown -R vscode:vscode /home/vscode/.m2 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..40b91f6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +{ + "name": "doma-spring-boot", + "build": { + "dockerfile": "Dockerfile" + }, + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "none", + "installMaven": "true", + "installGradle": "false" + }, + "ghcr.io/devcontainers/features/docker-in-docker:2": {} + }, + "mounts": [ + { + "source": "doma-spring-boot-maven", + "target": "/home/vscode/.m2", + "type": "volume" + }, + { + "source": "doma-spring-boot-dind", + "target": "/var/lib/docker", + "type": "volume" + } + ], + "customizations": { + "vscode": { + "extensions": [ + "vmware.vscode-boot-dev-pack" + ] + } + } +} \ No newline at end of file From aa552a0714e1438fc1fcb6602c8462ecf7874930 Mon Sep 17 00:00:00 2001 From: Uragami Taichi Date: Sat, 16 Aug 2025 16:10:53 +0900 Subject: [PATCH 2/6] Remove explicit Maven installation since Maven Wrapper is available Keep installing ghcr.io/devcontainers/features/java for convenient sdkman support. --- .devcontainer/devcontainer.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 40b91f6..44874b9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,9 +5,7 @@ }, "features": { "ghcr.io/devcontainers/features/java:1": { - "version": "none", - "installMaven": "true", - "installGradle": "false" + "version": "none" }, "ghcr.io/devcontainers/features/docker-in-docker:2": {} }, From 4f524b6ece578d6a018e135206d0f00984bb643e Mon Sep 17 00:00:00 2001 From: Uragami Taichi Date: Sat, 16 Aug 2025 16:19:33 +0900 Subject: [PATCH 3/6] Add comments --- .devcontainer/devcontainer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 44874b9..98109dc 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,9 +4,12 @@ "dockerfile": "Dockerfile" }, "features": { + // Since the base image is Java 17, set the version to "none" so Java is not installed here. + // However, using SDKMAN! is convenient, so we still use ghcr.io/devcontainers/features/java. "ghcr.io/devcontainers/features/java:1": { "version": "none" }, + // For using Testcontainers. "ghcr.io/devcontainers/features/docker-in-docker:2": {} }, "mounts": [ From a49d0dcf0e41b67da10cb686600c4c68e1eccc18 Mon Sep 17 00:00:00 2001 From: Uragami Taichi Date: Sat, 16 Aug 2025 16:46:45 +0900 Subject: [PATCH 4/6] Add VSCode extensions --- .devcontainer/devcontainer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 98109dc..51d3f07 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -27,7 +27,9 @@ "customizations": { "vscode": { "extensions": [ - "vmware.vscode-boot-dev-pack" + "vmware.vscode-boot-dev-pack", + "redhat.vscode-xml", + "redhat.vscode-yaml" ] } } From dbac751c9f4d49681c766f97154fb91940203cc6 Mon Sep 17 00:00:00 2001 From: Uragami Taichi Date: Sat, 16 Aug 2025 17:01:33 +0900 Subject: [PATCH 5/6] Setup pre-commit --- .devcontainer/devcontainer.json | 8 +++++++- .devcontainer/setup.sh | 2 ++ .pre-commit-config.yaml | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 .devcontainer/setup.sh create mode 100644 .pre-commit-config.yaml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 51d3f07..71bddad 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,7 +10,12 @@ "version": "none" }, // For using Testcontainers. - "ghcr.io/devcontainers/features/docker-in-docker:2": {} + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + // For using pre-commit. + "ghcr.io/devcontainers/features/python:1": { + "version": "3.12", + "toolsToInstall": "pre-commit" + } }, "mounts": [ { @@ -24,6 +29,7 @@ "type": "volume" } ], + "postCreateCommand": ".devcontainer/setup.sh", "customizations": { "vscode": { "extensions": [ diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100755 index 0000000..0650dae --- /dev/null +++ b/.devcontainer/setup.sh @@ -0,0 +1,2 @@ +#!/bin/bash +pre-commit install -t pre-commit -t pre-push diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..67e75bf --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: + + - repo: local + hooks: + - id: format + name: Format Java source code + entry: ./mvnw formatter:format -q + types: + - java + language: system + pass_filenames: false + stages: + - pre-commit + + - repo: local + hooks: + - id: verify + name: Verify + entry: ./mvnw verify + types: + - java + language: system + pass_filenames: false + stages: + - pre-push From aff128614f58e3eb7d98f0ce962dc99ee9eff4e8 Mon Sep 17 00:00:00 2001 From: Uragami Taichi Date: Sat, 16 Aug 2025 17:08:23 +0900 Subject: [PATCH 6/6] Ensure the Verify hook runs on any file change --- .pre-commit-config.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 67e75bf..9273382 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,8 +17,6 @@ repos: - id: verify name: Verify entry: ./mvnw verify - types: - - java language: system pass_filenames: false stages: