diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..da6b6c4ec8 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.20 + +RUN apt update && apt install -y sudo git + +ARG USERNAME=root +RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME + +ENV DEVCONTAINER=true + +COPY . . diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..627a381051 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,8 @@ +// See https://containers.dev/implementors/json_reference/ for configuration reference +{ + "name": "Kyverno", + "build": { + "dockerfile": "Dockerfile" + }, + "remoteUser": "root" +} diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 074badd0c9..01c40bb356 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -4,6 +4,7 @@ This document covers basic needs to work with Kyverno codebase. It contains instructions to build, run, and test Kyverno. +- [Open project in devcontainer](#open-project-in-devcontainer-recommended) - [Tools](#tools) - [Building local binaries](#building-local-binaries) - [Building kyvernopre locally](#building-kyvernopre-locally) @@ -27,6 +28,27 @@ It contains instructions to build, run, and test Kyverno. - [Generating helm charts docs](#generating-helm-charts-docs) - [Debugging local code](#debugging-local-code) +## Open project in devcontainer (recommended) +- Clone the project to your local machine. +- Make sure that you have the Visual Studio Code editor installed on your system. + +- Make sure that you have the Docker installed on your system. + +- Open the project in Visual Studio Code. + +- If you haven't already done so, install the **Dev Containers** extension in Visual Studio Code. + +- Once the extension is installed, you should see a green icon in the bottom left corner of the window. + +- After you have installed Dev Containers extension, it should automatically detect the .devcontainer folder inside the project, +and should suggest you to open the project in container. + +- If it doesn't suggest you, then press Ctrl + Shift + p and search "reopen in container" and click on it. + +- If everything goes well, the project should be opened in your devcontainer. + +- Then follow the steps as mentioned below to configure the project. + ## Tools Building and/or testing Kyverno requires additional tooling.