From 74dac65817c97b19b2b176a20bce0ee8d683bc8f Mon Sep 17 00:00:00 2001 From: ebolo Date: Tue, 29 Apr 2025 01:12:13 +0000 Subject: [PATCH] feat: add devcontainer --- .devcontainer/devcontainer.json | 48 +++++++++++++++++++++++++++++++++ CaddyManager.sln | 1 + compose.yaml | 12 +++++---- 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..90b7fa4 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,48 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet +{ + "name": "C# (.NET)", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/dotnet:1-9.0", + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [ + 8080 + ], + "mounts": [ + { + "source": "caddy-manager-data-protection", + "type": "volume", + "target": "/home/vscode/.aspnet/DataProtection-Keys" + }, + { + "source": "caddy-manager-configdir", + "type": "volume", + "target": "/home/vscode/caddy/config" + } + ], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "dotnet restore", + "postCreateCommand": { + "fixDataProtectionPerms": "sudo chown -R $(whoami): /home/vscode/.aspnet/DataProtection-Keys", + "fixCaddyConfigPerms": "sudo chown -R $(whoami): /home/vscode/caddy/config" + }, + // Configure tool-specific properties. + "customizations": { + "jetbrains": { + "backend": "Rider" + } + }, + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {} + }, + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" + "containerEnv": { + "Docker__CaddyContainerName": "caddy", + "Docker__DockerHost": "unix:///var/run/docker.sock", + "Caddy__ConfigDir": "/home/vscode/caddy/config", + } +} diff --git a/CaddyManager.sln b/CaddyManager.sln index 866f332..0b8acd3 100644 --- a/CaddyManager.sln +++ b/CaddyManager.sln @@ -5,6 +5,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EC202984-FC85-4101-B801-1E8AA4E9C4DD}" ProjectSection(SolutionItems) = preProject compose.yaml = compose.yaml + .devcontainer\devcontainer.json = .devcontainer\devcontainer.json EndProjectSection EndProject Global diff --git a/compose.yaml b/compose.yaml index 91058e1..b39ca24 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,6 +1,8 @@ services: - caddymanager: - image: caddymanager - build: - context: . - dockerfile: CaddyManager/Dockerfile + caddy: + image: caddy:latest + container_name: caddy + restart: always + network_mode: "host" + security_opt: + - label:disable \ No newline at end of file