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..71bddad --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,42 @@ +{ + "name": "doma-spring-boot", + "build": { + "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": {}, + // For using pre-commit. + "ghcr.io/devcontainers/features/python:1": { + "version": "3.12", + "toolsToInstall": "pre-commit" + } + }, + "mounts": [ + { + "source": "doma-spring-boot-maven", + "target": "/home/vscode/.m2", + "type": "volume" + }, + { + "source": "doma-spring-boot-dind", + "target": "/var/lib/docker", + "type": "volume" + } + ], + "postCreateCommand": ".devcontainer/setup.sh", + "customizations": { + "vscode": { + "extensions": [ + "vmware.vscode-boot-dev-pack", + "redhat.vscode-xml", + "redhat.vscode-yaml" + ] + } + } +} \ No newline at end of file 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..9273382 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +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 + language: system + pass_filenames: false + stages: + - pre-push