From 621ff7e816364f79a99a88e604e7edcf58b85e60 Mon Sep 17 00:00:00 2001 From: moreal Date: Thu, 24 Oct 2024 14:24:34 +0000 Subject: [PATCH] Recover devcontainer --- .devcontainer/bin/postAttachCommand.sh | 3 ++ .devcontainer/bin/postCreateCommand.sh | 8 ++++ .devcontainer/devcontainer.json | 54 ++++++++++++---------- .devcontainer/docker-compose.yml | 7 +++ .devcontainer/scripts/postCreateCommand.sh | 4 -- .gitignore | 2 + docker-compose.yml | 6 +++ 7 files changed, 55 insertions(+), 29 deletions(-) create mode 100755 .devcontainer/bin/postAttachCommand.sh create mode 100755 .devcontainer/bin/postCreateCommand.sh create mode 100644 .devcontainer/docker-compose.yml delete mode 100644 .devcontainer/scripts/postCreateCommand.sh create mode 100644 docker-compose.yml diff --git a/.devcontainer/bin/postAttachCommand.sh b/.devcontainer/bin/postAttachCommand.sh new file mode 100755 index 00000000..7cdce11d --- /dev/null +++ b/.devcontainer/bin/postAttachCommand.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +dotnet restore diff --git a/.devcontainer/bin/postCreateCommand.sh b/.devcontainer/bin/postCreateCommand.sh new file mode 100755 index 00000000..0f1c6339 --- /dev/null +++ b/.devcontainer/bin/postCreateCommand.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -ev + +sudo apt update -qq +sudo apt install -qq -y vim + +git config core.editor "vim" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d47a1226..619f4765 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,33 +1,37 @@ -// 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-8.0-bookworm", + "name": "Mimir & Mimir.Worker", + "dockerComposeFile": [ + "../docker-compose.yml", + "docker-compose.yml" + ], + "service": "devcontainer", + "workspaceFolder": "/workspace", "features": { - "ghcr.io/devcontainers/features/dotnet:2": {}, - "ghcr.io/devcontainers/features/github-cli:1": {}, - "ghcr.io/devcontainers-contrib/features/mongodb-atlas-cli-homebrew:1": {}, - "ghcr.io/devcontainers-contrib/features/mongosh-homebrew:1": {} + "ghcr.io/devcontainers/features/dotnet:2": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/github-cli:1": {} }, - - // 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": [5195, 7272], + "forwardPorts": [7272, 27017], "portsAttributes": { "7272": { + "label": "MongoDB", "protocol": "https" - } + }, + "27017": { + "label": "MongoDB" + } }, - - // Use 'postCreateCommand' to run commands after the container is created. - "postAttachCommand": "./.devcontainer/scripts/postCreateCommand.sh" - - // Configure tool-specific properties. - // "customizations": {}, - - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" + "postCreateCommand": "./.devcontainer/bin/postCreateCommand.sh", + "postAttachCommand": "./.devcontainer/bin/postAttachCommand.sh", + "customizations": { + "vscode": { + "extensions": [ + "ms-dotnettools.vscode-dotnet-runtime", + "ms-dotnettools.csharp", + "ms-dotnettools.csdevkit", + "mongodb.mongodb-vscode" + ] + } + } } diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 00000000..cfffb7de --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,7 @@ +services: + devcontainer: + image: mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm + volumes: + - .:/workspace + network_mode: service:mongo + command: sleep infinity diff --git a/.devcontainer/scripts/postCreateCommand.sh b/.devcontainer/scripts/postCreateCommand.sh deleted file mode 100644 index 69715192..00000000 --- a/.devcontainer/scripts/postCreateCommand.sh +++ /dev/null @@ -1,4 +0,0 @@ -dotnet restore -dotnet tool restore -dotnet graphql generate Mimir -dotnet graphql generate Mimir.Worker diff --git a/.gitignore b/.gitignore index 1a869e72..c8e3ff00 100644 --- a/.gitignore +++ b/.gitignore @@ -291,3 +291,5 @@ obj/ Generated appsettings.local.json + +!.devcontainer/bin diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..f13a8cb3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +services: + mongo: + image: mongo:latest + restart: unless-stopped + ports: + - "27017:27017"