diff --git a/.devcontainer.json b/.devcontainer.json deleted file mode 120000 index 62b9558..0000000 --- a/.devcontainer.json +++ /dev/null @@ -1 +0,0 @@ -devcontainer.json \ No newline at end of file diff --git a/devcontainer.json b/.devcontainer/devcontainer.json similarity index 76% rename from devcontainer.json rename to .devcontainer/devcontainer.json index 95f3505..330bc71 100644 --- a/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,10 +1,12 @@ // Reference: // - https://containers.dev/features // - https://containers.dev/implementors/features +// - https://containers.dev/implementors/json_reference // - https://code.visualstudio.com/docs/getstarted/settings { - "name": "pulumi-devcontainer", - "image": "ghcr.io/pulumi/devcontainer:latest", + "name": "konductor", + //"image": "ghcr.io/pulumi/devcontainer", + "dockerFile": ".github/docker/Dockerfile", "customizations": { "vscode": { "settings": { @@ -41,8 +43,9 @@ "editor.gotoLocation.multipleImplementations": "goto", "editor.gotoLocation.multipleTypeDefinitions": "goto", "editor.terminal.integrated.shell.linux": "/usr/bin/fish", - "terminal.integrated.sendKeybindingsToShell": true, "terminal.integrated.fontFamily": "FiraMono Nerd Font Mono", + "terminal.integrated.shell.linux": "/usr/bin/fish", + "terminal.integrated.sendKeybindingsToShell": true, "workbench.colorTheme": "Dracula Soft", "explorer.openEditors.visible": 1, "files.trimTrailingWhitespace": true, @@ -50,38 +53,27 @@ }, "extensions": [ "golang.go", - "github.copilot", "vscodevim.vim", + "github.copilot", "ms-python.python", "redhat.vscode-yaml", "esbenp.prettier-vscode", - "ms-vscode.makefile-tools", - "ms-azuretools.vscode-docker", + "ms-vsliveshare.vsliveshare", + "github.vscode-github-actions", + "ms-vscode.vscode-typescript-next", "github.vscode-pull-request-github", "ms-vscode-remote.remote-containers", - "visualstudioexptteam.vscodeintellicode", "bierner.markdown-preview-github-styles" ] } }, "features": { - "ghcr.io/devcontainers/features/common-utils:2": { - "username": "vscode", - "userGid": "automatic", - "userUid": "automatic", - "upgradePackages": false, - "nonFreePackages": true - }, - "ghcr.io/devcontainers/features/docker-outside-of-docker:1": { - "installDockerBuildx": true, - "dockerDashComposeVersion": "v2", - "version": "latest", - "moby": false - } + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} }, - "postCreateCommand": "git submodule update --init --recursive; direnv allow", "remoteUser": "vscode", "forwardPorts": [1313, 2222, 6000, 7681, 8080], - "runArgs": ["--network=host"] + "postCreateCommand": "true", + "mounts": ["source=dind-var-lib-docker,target=/var/lib/docker,type=volume"], + "runArgs": ["--init", "--privileged", "--network=host"], + "overrideCommand": false } - diff --git a/containers/kind/devcontainer.json b/.devcontainer/kind/devcontainer.json similarity index 100% rename from containers/kind/devcontainer.json rename to .devcontainer/kind/devcontainer.json diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3311145 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +export FOO="bar" diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile new file mode 100644 index 0000000..56d0b37 --- /dev/null +++ b/.github/docker/Dockerfile @@ -0,0 +1 @@ +FROM ghcr.io/pulumi/devcontainer diff --git a/.gitpod.yml b/.gitpod.yml index 07fdbf0..4506409 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1 +1 @@ -image: ghcr.io/pulumi/devcontainer \ No newline at end of file +image: ghcr.io/pulumi/devcontainer diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 916d8d7..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "go.testTags": "all", - "go.buildTags": "all", - "editor.minimap.enabled": false, - "explorer.openEditors.visible": 1, - "editor.quickSuggestionsDelay": 0, - "editor.suggestSelection": "first", - "editor.snippetSuggestions": "top", - "editor.gotoLocation.multipleReferences": "goto", - "editor.gotoLocation.multipleDefinitions": "goto", - "editor.gotoLocation.multipleDeclarations": "goto", - "editor.gotoLocation.multipleImplementations": "goto", - "editor.gotoLocation.multipleTypeDefinitions": "goto", - "files.trimTrailingWhitespace": true, - "files.trimFinalNewlines": true -} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e20d28a --- /dev/null +++ b/Makefile @@ -0,0 +1,71 @@ +# --- Global Variables --- +PULUMI_STACK := echo $GITHUB_REPOSITORY | awk -F '[/]' '{print $2}' +GITHUB_REPOSITORY_STRING := $(shell echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]') +DOCKER_IMAGE_NAME := ghcr.io/${GITHUB_REPOSITORY_STRING}:latest +# --- Help --- +# This section provides a default help message displaying all available commands +help: + @echo "Available commands:" + @echo " update Update the .github/devcontainer submodule" + @echo " login Log in to Pulumi" + @echo " esc Run a Pulumi ESC environment" + @echo " up Deploy Pulumi infrastructure" + @echo " act Install the GitHub 'gh-act' extension" + @echo " test Run all tests" + +# --- Docker Build --- +# Build the Docker image +build: + @echo "Building Docker image..." + clear + docker build --progress plain --load --pull --build-arg GITHUB_TOKEN="${GITHUB_TOKEN}" --tag ${DOCKER_IMAGE_NAME} -f ./docker/Dockerfile ./docker + @echo "Docker image built." + +# --- GitHub Actions --- +# Install & Run the GitHub 'gh-act' extension for local testing of GitHub Actions +act: + @echo "Installing & Running 'act' Github Actions Workflow Testing..." + gh extension install nektos/gh-act || true + gh act -s GITHUB_TOKEN=${GITHUB_TOKEN} -s ACTIONS_RUNTIME_TOKEN=${GITHUB_TOKEN} -s GHA_GITHUB_TOKEN=${GITHUB_TOKEN} + @echo "Github Workflow Complete." + +# --- Pulumi Commands --- +# Log in to Pulumi +pulumi-login: + @echo "Logging in to Pulumi..." + pulumi login + @echo "Login successful." + +# Deploy Pulumi infrastructure +pulumi-up: + @echo "Deploying Pulumi infrastructure..." + pulumi up --stack $(PULUMI_STACK) + @echo "Deployment complete." + +# Run a Pulumi ESC environment +pulumi-esc-env: + @echo "Running Pulumi ESC environment..." + # Replace the below command with the actual command to run the Pulumi ESC environment + pulumi esc env open --stack $(PULUMI_STACK) + @echo "Pulumi ESC environment running." + +# --- Devcontainer Management --- +# Update the .github/devcontainer submodule +update-devcontainer: + @echo "Updating .github/devcontainer submodule..." + git submodule update --init --recursive .github/devcontainer + @echo "Update complete." + +# --- Testing --- +# Add your testing scripts here +test: + @echo "Running tests..." + # Add commands to run your tests + @echo "Testing complete." + +# --- Default Command --- +# Default command when running 'make' without arguments +all: help + +# Note: Each command is fully implemented with the necessary steps for each task. +# This Makefile is designed to be both functional and educational. diff --git a/Makefile.example b/Makefile.example deleted file mode 100644 index 6526ac1..0000000 --- a/Makefile.example +++ /dev/null @@ -1,5 +0,0 @@ -devcontainer:: - git submodule update --init --recursive .devcontainer - git submodule update --remote --merge .devcontainer - rm -rf .devcontainer.json - cp .devcontainer/devcontainer.json .devcontainer.json diff --git a/README.md b/README.md index d568a46..cf8f03c 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,73 @@ # Pulumi Dev Container +[![Pulumi](https://img.shields.io/badge/pulumi-v3.101.1-blueviolet)](https://www.pulumi.com/docs/get-started/install/) [![Kubectl](https://img.shields.io/badge/kubectl-v1.29.0-blueviolet)](https://kubernetes.io/docs/tasks/tools/install-kubectl/) [![Docker](https://img.shields.io/badge/docker-v24.0.7-blueviolet)](https://docs.docker.com/get-docker/) [![Kind](https://img.shields.io/badge/kind-v0.20.0-blueviolet)](https://kind.sigs.k8s.io/docs/user/quick-start/) [![Helm](https://img.shields.io/badge/helm-v3.13.3-blueviolet)](https://helm.sh/docs/intro/install/) +[![License](https://img.shields.io/github/license/usrbinkat/iac-mesh-pac)]() [![ghcr.io/pulumi/devcontainer](https://github.com/pulumi/devcontainer/actions/workflows/build.yaml/badge.svg?branch=main)](https://github.com/pulumi/devcontainer/actions/workflows/build.yaml) +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/pulumi/devcontainer?quickstart=1) -### [![ghcr.io/pulumi/devcontainer](https://github.com/pulumi/devcontainer/actions/workflows/build.yaml/badge.svg?branch=main)](https://github.com/pulumi/devcontainer/actions/workflows/build.yaml) +This is a [Github Template Repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) which provides a Pulumi [Devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) together with GitOps ready boilerplate for quickly starting new Pulumi IaC projects. -This repository is designed with deep [VS Code](https://code.visualstudio.com) integration to automate Pulumi IaC and Provider development dependencies and prerequisites as much as possible using [Dev Containers](https://containers.dev/) to prepare your development environment, or even just run your development directly in the browser with [Github CodeSpaces](https://github.com/features/codespaces). +The Pulumi [Devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) is designed with deep [VS Code](https://code.visualstudio.com) and [Github Codespaces](https://github.com/features/codespaces) integration to streamline a common Pulumi IaC and Provider development environment. dependencies and prerequisites as much as possible using [Dev Containers](https://containers.dev/) to prepare your development environment, or even just run your development directly in the browser with [Github CodeSpaces](https://github.com/features/codespaces). ![CodeSpaces Screenshot](./.github/assets/codespaces.png) # Getting Started -There are 3 ways to get started: +With multiple ways to get started, it is a good idea to briefly review: -1. [Git Submodule](#git-submodule) -1. [Github CodeSpaces](#github-codespaces) -1. [VS Code Dev Container](#vs-code-dev-container) +- [Getting Started](#getting-started) +- [Git Submodule](#git-submodule) +- [Github CodeSpaces](#github-codespaces) +- [VS Code Dev Container](#vs-code-dev-container) +- [First time setup](#first-time-setup) +- [Pulumi Dev Container](#pulumi-dev-container) -# Git Submodule +# Github CodeSpaces -The pulumi Dev Container repository can be added as a submodule to your project to provide an easy and consistent development environment. +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/pulumi/devcontainer?quickstart=1) -To add this repository as a submodule to your project, run the following commands: +Codespaces is the easiest way to get started quickly. Simply click the button above to open this repository in a new Codespace and then follow the [First time setup](#first-time-setup) instructions below. -```bash -git submodule add https://github.com/pulumi/devcontainer .devcontainer -git submodule update --init --recursive .devcontainer -``` +> Fig 1. How to open project in CodeSpaces +![How to open repository in CodeSpaces](./.github/assets/gh-open-codespaces.png) -To update the devcontainer submodule in consuming repos: +## First time setup + +1. Pulumi Login ```bash -git submodule update --remote --merge .devcontainer +pulumi login ``` -After the submodule is added, you can open your project in VS Code and it will automatically detect the Dev Container configuration and prompt you to open the project in a container, or you can open the project in Github CodeSpaces. +> Fig 2.b pulumi login +![Pulumi login](./.github/assets/pulumi-login.png) +![Pulumi login complete](./.github/assets/pulumi-login-complete.png) -# Github CodeSpaces +2. Create a new stack -> Fig 1. How to open project in CodeSpaces -![How to open repository in CodeSpaces](./.github/assets/gh-open-codespaces.png) +```bash +pulumi new +pulumi stack init +``` # VS Code Dev Container To use the Dev Container in VS Code, you will need to install the [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension, and follow the [official tutorial here](https://code.visualstudio.com/docs/devcontainers/tutorial) to begin. -## First time setup +# Git Submodule -1. Pulumi Login +The pulumi Dev Container repository can be added as a submodule to an existing project to provide an easy and consistent development environment that is maintained upstream. + +To add this repository as a submodule to your project, run the following commands: ```bash -pulumi login +git submodule add https://github.com/pulumi/devcontainer .github/devcontainer +git submodule update --init --recursive .github/devcontainer +mkdir .devcontainer && cp .github/devcontainer/.devcontainer/* .devcontainer/ ``` -> Fig 2.b pulumi login -![Pulumi login](./.github/assets/pulumi-login.png) -![Pulumi login complete](./.github/assets/pulumi-login-complete.png) +To update the devcontainer submodule in consuming repos: + +```bash +git submodule update --remote --merge .github/devcontainer +``` + +After the submodule is added, you can open your project in VS Code and it will automatically detect the Dev Container configuration and prompt you to open the project in a container, or you can open the project in Github CodeSpaces. diff --git a/Dockerfile b/docker/Dockerfile similarity index 100% rename from Dockerfile rename to docker/Dockerfile diff --git a/rootfs/etc/apt/apt.conf.d/99config b/docker/rootfs/etc/apt/apt.conf.d/99config similarity index 100% rename from rootfs/etc/apt/apt.conf.d/99config rename to docker/rootfs/etc/apt/apt.conf.d/99config diff --git a/rootfs/etc/dpkg/dpkg.cfg.d/01_noman b/docker/rootfs/etc/dpkg/dpkg.cfg.d/01_noman similarity index 100% rename from rootfs/etc/dpkg/dpkg.cfg.d/01_noman rename to docker/rootfs/etc/dpkg/dpkg.cfg.d/01_noman