From 9ac50c787edea98f3e0e1b6c5d562b3d5a2617db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20L=C3=BCscher?= Date: Fri, 26 Apr 2024 21:29:40 +0000 Subject: [PATCH] refactor(devcontainer): new devcontainer specification based on debian with debian based container features such as poetry, black etc. can be more easily integrated --- .devcontainer/devcontainer.json | 112 +++++++++++++++-------------- .devcontainer/forge.code-workspace | 10 +-- .devcontainer/install-dev-tools.sh | 36 +++------- .github/dependabot.yml | 11 +-- .markdownlint.json | 3 - .markdownlint.yml | 10 +++ .prettierrc | 3 - .prettierrc.yml | 3 + .vscode/cspell_custom.txt | 1 + 9 files changed, 94 insertions(+), 95 deletions(-) delete mode 100644 .markdownlint.json create mode 100644 .markdownlint.yml delete mode 100644 .prettierrc create mode 100644 .prettierrc.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 884b22c..ab4b69b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,98 +1,104 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/alpine +// README at: https://github.com/devcontainers/templates/tree/main/src/debian { "name": "ublue-os/forge", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/base:alpine-3.17", - // Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "image": "mcr.microsoft.com/devcontainers/base:bookworm", + "features": { + "ghcr.io/devcontainers/features/python:1": { + "installTools": true, + "version": "3.11" + }, + "ghcr.io/devcontainers-contrib/features/black:2": { + "version": "24.4.1" + }, + "ghcr.io/devcontainers-contrib/features/poetry:2": { + "version": "1.8.2" + } + }, + // Container user definition - This is needed for compatibility with podman -> https://github.com/containers/podman/issues/15001#issuecomment-1193321924 "remoteUser": "vscode", - // podman needs this "containerUser": "vscode", - "runArgs": [ - // run container as current user - "--userns=keep-id", - // disable selinux isolation that breaks bind mounts - "--security-opt=label=disable" - ], - // Configure environment variables + // Container environment variables "containerEnv": { "POETRY_VIRTUALENVS_CREATE": "false", - "POETRY_VERSION": "1.3.1" + "LAZYGIT_VERSION": "0.41.0" }, - "remoteEnv": { - // Add path for packages installed with poetry - "PATH": "${containerEnv:PATH}:/home/vscode/.local/bin:/home/vscode/.local/pipx/venvs/poetry/bin" - }, - // Mounts from host system - "mounts": [ - "source=/run/user/${localEnv:UID:1000}/podman/podman.sock,target=/run/podman/podman.sock,type=bind" - ], - // Install DevTools + // Install and configure DEV tools "postCreateCommand": "bash ./.devcontainer/install-dev-tools.sh", - // Configure tool-specific properties. + // VSCode settings "customizations": { "vscode": { "settings": { + // Terminal settings + "terminal.integrated.defaultProfile.linux": "zsh", "terminal.integrated.profiles.linux": { + "bash": { + "path": "bash", + "icon": "terminal-bash" + }, "zsh": { - "path": "zsh", - "args": ["-l"] + "path": "zsh" } }, - "terminal.integrated.defaultProfile.linux": "zsh", - "terminal.integrated.automation.linux": "zsh", - "terminal.integrated.automationProfile.linux": { "path": "zsh" }, + // Editor settings "editor.suggestSelection": "first", "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, "editor.formatOnPaste": true, "files.associations": { - "**/ansible/**/*.yml": "ansible" + ".ansible-lint": "yaml", + ".gitmessage": "git-commit", + "**/pb_*.yml": "ansible", + "**/playbooks/*.yml": "ansible", + "**/roles/**/tasks/*.yml": "ansible", + "inventory_*": "ansible" }, - "[ansible]": { - "editor.defaultFormatter": "redhat.ansible", - "editor.formatOnPaste": true, - "editor.insertSpaces": true, - "editor.tabSize": 2 - }, - // "ansible.ansible.path": "/home/vscode/.local/bin/ansible", - // "ansible.python.interpreterPath": "/usr/local/bin/python3", - "ansible.ansible.useFullyQualifiedCollectionNames": true, - "ansible.ansibleLint.enabled": true, - // "ansible.ansibleLint.path": "/home/vscode/.local/bin/ansible-lint", - "ansible.ansibleLint.arguments": "-c ${containerWorkspaceFolder}/ansible/.ansible-lint", + // Ansible configuration + "ansible.validation.enabled": true, + "ansible.validation.lint.arguments": "-c .ansible-lint", + "ansible.ansible.reuseTerminal": true, + "ansible.lightspeed.enabled": true, + "ansible.lightspeed.suggestions.enabled": true, + "ansible.lightspeed.URL": "https://c.ai.ansible.redhat.com", + // Template configuration + "templates.folder": "./.vscode/templates", + // Spell-Check configuration "cSpell.customDictionaries": { "project-words": { "name": "custom-dictionary", - "path": "${workspaceFolder}/.vscode/cspell_custom.txt", + "path": "${workspaceRoot}/.vscode/cspell_custom.txt", "description": "Words used in this project", "addWords": true }, "custom": true, "internal-terms": false }, - "docker.host": "unix:///run/podman/podman.sock", + // Workspace colors "peacock.affectActivityBar": false, "peacock.affectStatusBar": true, "peacock.affectTitleBar": false, "peacock.surpriseMeOnStartup": false }, + // VSCode Extensions installed in DevContainer "extensions": [ - "bungcip.better-toml", - "DavidAnson.vscode-markdownlint", + "be5invis.toml", + "codezombiech.gitignore", + "davidanson.vscode-markdownlint", "esbenp.prettier-vscode", - "GitHub.vscode-pull-request-github", - "Gruntfuggly.todo-tree", - "jamesls.jmespath-vscode", - "kokakiwi.vscode-just", + "gitlab.gitlab-workflow", + "gruntfuggly.todo-tree", + "johnpapa.vscode-peacock", "ms-azuretools.vscode-docker", - "ms-kubernetes-tools.vscode-kubernetes-tools", - "nico-castell.linux-desktop-file", + "ms-python.autopep8", + "ms-python.black-formatter", + "ms-python.python", + "mutantdino.resourcemonitor", "redhat.ansible", "redhat.vscode-yaml", - "samuelcolvin.jinjahtml", - "shakram02.bash-beautify", - "streetsidesoftware.code-spell-checker" + "streetsidesoftware.code-spell-checker-german", + "streetsidesoftware.code-spell-checker", + "tamasfe.even-better-toml" ] } } diff --git a/.devcontainer/forge.code-workspace b/.devcontainer/forge.code-workspace index 4d5acc7..63f10f6 100644 --- a/.devcontainer/forge.code-workspace +++ b/.devcontainer/forge.code-workspace @@ -6,14 +6,14 @@ ], "settings": { "workbench.colorCustomizations": { - "sash.hoverBorder": "#7cb9e3", - "statusBar.background": "#52a2da", - "statusBarItem.hoverBackground": "#2c8bcd", - "statusBarItem.remoteBackground": "#52a2da", + "sash.hoverBorder": "#a1cfe7", + "statusBar.background": "#78badd", + "statusBarItem.hoverBackground": "#4fa5d3", + "statusBarItem.remoteBackground": "#78badd", "statusBar.foreground": "#15202b", "statusBarItem.remoteForeground": "#15202b" }, - "peacock.remoteColor": "#52a2da", + "peacock.remoteColor": "#78badd", "cSpell.enableFiletypes": ["ansible", "shellscript"] } } diff --git a/.devcontainer/install-dev-tools.sh b/.devcontainer/install-dev-tools.sh index e7eb56e..416b9b3 100644 --- a/.devcontainer/install-dev-tools.sh +++ b/.devcontainer/install-dev-tools.sh @@ -1,10 +1,3 @@ -#!/bin/bash -cat < version specified in devcontainer.json +LAZYGIT_SOURCE=https://github.com/jesseduffield/lazygit/releases/download/v${LAZYGIT_VERSION}/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz +LAZYGIT_TMP=/tmp/lazygit.tar.gz +wget -O $LAZYGIT_TMP $LAZYGIT_SOURCE +sudo tar -xf $LAZYGIT_TMP -C /usr/bin # Add git commit template echo "" @@ -45,11 +28,12 @@ echo -e "${YELLOW}Configuring git${ENDCOLOR}" echo "" git config --local commit.template .gitmessage + # Install python dependencies echo "" -echo -e "${YELLOW}Installing python dependencies${ENDCOLOR}" +echo -e "${YELLOW}Installing project dependencies${ENDCOLOR}" echo "" -poetry install -C /workspaces/forge/setup/ansible +poetry install --no-root -C /workspaces/forge/setup/ansible # Install ansible dependencies # echo "" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 90e05c4..f33a02c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,11 +1,12 @@ # To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: +# Please see the documentation for more information: # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot version: 2 updates: - - package-ecosystem: "github-actions" # See documentation for possible values - directory: "/" # Location of package manifests - schedule: - interval: "weekly" + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/.markdownlint.json b/.markdownlint.json deleted file mode 100644 index 8b4473c..0000000 --- a/.markdownlint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "MD024": { "allow_different_nesting": true } -} diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 0000000..9b9ab10 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,10 @@ +--- +# Markdown Lint Configuration -> https://github.com/DavidAnson/vscode-markdownlint?tab=readme-ov-file#rules +MD013: + line_length: 90 + tables: false + code_blocks: false +MD024: + siblings_only: true +MD046: + style: fenced diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 75fa134..0000000 --- a/.prettierrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "tabWidth": 2 -} diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000..983f2a2 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,3 @@ +--- +# prettier configuration settings -> https://prettier.io/docs/en/configuration +tabWidth: 2 diff --git a/.vscode/cspell_custom.txt b/.vscode/cspell_custom.txt index 813a40c..eb33ee2 100644 --- a/.vscode/cspell_custom.txt +++ b/.vscode/cspell_custom.txt @@ -7,6 +7,7 @@ getent gitmessage hostvars keygen +LAZYGIT lineinfile minica Mountpoint