From 567666512a8057bbaf1cd28c7a4cf72db79a13ac Mon Sep 17 00:00:00 2001 From: JoftheV <162925657+JoftheV@users.noreply.github.com> Date: Sat, 19 Oct 2024 22:16:59 -0500 Subject: [PATCH] Create devcontainer.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An extended description of the provided devcontainer.json configuration for your Open5GS and NeonBot project. This explanation will cover each section and its purpose, offering insights into how this configuration supports development in a Codespace environment. Extended Description of devcontainer.json { "image": "mcr.microsoft.com/devcontainers/universal:2", "features": { "docker-in-docker": { "version": "latest" }, "ghcr.io/devcontainers/features/common-utils:1": {}, "ghcr.io/devcontainers/features/git:1": {} }, "customizations": { "vscode": { "extensions": [ "ms-vscode.cpptools", "streetsidesoftware.code-spell-checker", "yzhang.markdown-all-in-one", "dbaeumer.vscode-eslint", "oderwat.indent-rainbow", "eamodio.gitlens" ] } }, "workspaceFolder": "/workspace", "remoteUser": "root", "postCreateCommand": "apt-get update && apt-get install -y build-essential cmake pkg-config git libgnutls28-dev libsctp-dev libssl-dev mongo-tools mongodb libcurl4-openssl-dev libsctp1 lksctp-tools iproute2 && npm install -g npm@latest", "mounts": [ "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached" ], "onCreateCommand": [ "git clone https://github.com/open5gs/open5gs.git /workspace/open5gs", "cd /workspace/open5gs && meson build && ninja -C build", "mkdir /workspace/neonbot", "cd /workspace/neonbot && npm init -y && npm install axios ws discord.js" ], "forwardPorts": [3000, 3001, 27017, 5000], "portsAttributes": { "3000": { "label": "Web UI", "onAutoForward": "notify" }, "3001": { "label": "Web Console", "onAutoForward": "notify" }, "27017": { "label": "MongoDB", "onAutoForward": "silent" }, "5000": { "label": "API Server", "onAutoForward": "notify" } } } Detailed Breakdown 1. Image: • "image": "mcr.microsoft.com/devcontainers/universal:2": This specifies the base image for the container environment. The universal image provides a lightweight, flexible starting point compatible with various tools and frameworks. 2. Features: • "docker-in-docker": This feature allows running Docker containers inside the Codespace container. It’s useful for building and testing containerized applications. • "ghcr.io/devcontainers/features/common-utils:1": Installs a set of commonly used utilities that enhance the development experience, such as text editors and file manipulation tools. • "ghcr.io/devcontainers/features/git:1": Ensures that Git is installed, enabling version control and repository management. 3. Customizations: • VS Code Extensions: The specified extensions enhance the development experience by providing additional functionalities: • ms-vscode.cpptools: For C/C++ development. • streetsidesoftware.code-spell-checker: Helps with spell checking in your code comments and documentation. • yzhang.markdown-all-in-one: A comprehensive Markdown editor. • dbaeumer.vscode-eslint: Integrates ESLint for JavaScript and TypeScript linting. • oderwat.indent-rainbow: Visualizes indentation levels to improve code readability. • eamodio.gitlens: Provides powerful Git capabilities directly within the editor. 4. Workspace Folder: • "workspaceFolder": "/workspace": This sets the default directory where your project files will reside within the container. It helps organize the workspace and ensures all commands run in the correct context. 5. Remote User: • "remoteUser": "root": Specifies that the root user will be used within the container, allowing for unrestricted access to install packages and modify configurations. 6. Post Create Command: • "postCreateCommand": This command runs after the container is created and updates the package manager, installs necessary development tools and libraries, including: • Build tools like build-essential and cmake. • Libraries required for Open5GS, such as libgnutls28-dev, libsctp-dev, and libssl-dev. • MongoDB-related tools (mongo-tools, mongodb) for managing the database. • npm is also updated to the latest version to ensure compatibility with the latest packages. 7. Mounts: • "mounts": This section defines how local files are bound to the container. The local workspace is mounted to /workspace in the container, ensuring that any changes made in the Codespace reflect locally and vice versa. 8. On Create Command: • "onCreateCommand": This array defines commands that run upon the creation of the container: • Clones the Open5GS repository from GitHub into the workspace. • Builds the Open5GS project using meson and ninja. • Sets up the NeonBot directory, initializes it with npm, and installs required Node.js packages such as axios, ws, and discord.js. 9. Forward Ports: • "forwardPorts": This specifies which ports to forward from the container to the host machine. Forwarding allows you to access services running inside the container: • 3000: Typically used for a web UI. • 3001: Used for a web console. • 27017: Default MongoDB port. • 5000: Commonly used for API servers. 10. Ports Attributes: • "portsAttributes": This section configures how the forwarded ports are presented in the UI: • Labels each port for easy identification. • Configures notifications for auto-forwarding events, such as when a port is automatically forwarded to your host machine. Conclusion This devcontainer.json file is tailored for developing Open5GS and NeonBot applications in a streamlined and efficient environment. It ensures that all necessary tools and libraries are readily available, enhancing productivity and facilitating a smooth development workflow. This configuration will allow developers to focus on writing code without worrying about setting up their local environment, as everything is handled within the Codespace container. --- .devcontainer/devcontainer.json | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..c6171659d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,53 @@ +{ + "image": "mcr.microsoft.com/devcontainers/universal:2", + "features": { + "docker-in-docker": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/common-utils:1": {}, + "ghcr.io/devcontainers/features/git:1": {} + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.cpptools", + "streetsidesoftware.code-spell-checker", + "yzhang.markdown-all-in-one", + "dbaeumer.vscode-eslint", + "oderwat.indent-rainbow", + "eamodio.gitlens" + ] + } + }, + "workspaceFolder": "/workspace", + "remoteUser": "root", + "postCreateCommand": "apt-get update && apt-get install -y build-essential cmake pkg-config git libgnutls28-dev libsctp-dev libssl-dev mongo-tools mongodb libcurl4-openssl-dev libsctp1 lksctp-tools iproute2 && npm install -g npm@latest", + "mounts": [ + "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached" + ], + "onCreateCommand": [ + "git clone https://github.com/open5gs/open5gs.git /workspace/open5gs", + "cd /workspace/open5gs && meson build && ninja -C build", + "mkdir /workspace/neonbot", + "cd /workspace/neonbot && npm init -y && npm install axios ws discord.js" + ], + "forwardPorts": [3000, 3001, 27017, 5000], + "portsAttributes": { + "3000": { + "label": "Web UI", + "onAutoForward": "notify" + }, + "3001": { + "label": "Web Console", + "onAutoForward": "notify" + }, + "27017": { + "label": "MongoDB", + "onAutoForward": "silent" + }, + "5000": { + "label": "API Server", + "onAutoForward": "notify" + } + } +}