From 70ddc634f6c7972eeb6f33213429454ba6077606 Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Thu, 19 May 2022 11:55:56 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20Feat:=20=E6=B7=BB=E5=8A=A0=20devco?= =?UTF-8?q?ntainer=20=E6=94=AF=E6=8C=81=20(#981)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/Dockerfile | 20 ++++++++ .devcontainer/devcontainer.json | 83 +++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 4 ++ 3 files changed, 107 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..a8f735dd --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,20 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/codespaces-linux/.devcontainer/base.Dockerfile + +FROM mcr.microsoft.com/vscode/devcontainers/universal:linux + +# ** [Optional] Uncomment this section to install additional packages. ** +# USER root +# +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +USER codespace + +# [Required] Poetry +RUN curl -sSL https://install.python-poetry.org | python - -y +RUN poetry config virtualenvs.in-project true + +# [Required] Gitmoji CLI +# Deprecated: Maybe removed once nonemoji is done +RUN yarn global add gitmoji-cli +ENV PATH="$PATH:/home/codespace/.yarn/bin" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..c800d487 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,83 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/codespaces-linux +{ + "name": "NoneBot", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "/go", + "python.defaultInterpreterPath": "/opt/python/latest/bin/python", + "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", + "python.formatting.blackPath": "/usr/local/py-utils/bin/black", + "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", + "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", + "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", + "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", + "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", + "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", + "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint", + "python.analysis.diagnosticMode": "workspace", + "python.analysis.typeCheckingMode": "basic", + "[python]":{ + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[html]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "lldb.executable": "/usr/bin/lldb", + "files.exclude": { + "**/__pycache__": true + }, + "files.watcherExclude": { + "**/target/**": true, + "**/__pycache__": true + } + }, + "remoteUser": "codespace", + "overrideCommand": false, + "mounts": ["source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"], + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined", + "--privileged", + "--init" + ], + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "GitHub.vscode-pull-request-github", + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.isort", + "ms-python.black-formatter", + "EditorConfig.EditorConfig", + "esbenp.prettier-vscode", + "bradlc.vscode-tailwindcss" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // "oryx build" will automatically install your dependencies and attempt to build your project + "postCreateCommand": "poetry install -E all && poetry run pre-commit install && yarn install" +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7ae61bb1..563211c8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,6 +34,10 @@ yarn global add gitmoji-cli gitmoji -i ``` +### 使用 GitHub Codespaces (Dev Container) + +使用 GitHub Codespaces 选择 `NoneBot2` 项目,然后选择 `.devcontainer/devcontainer.json` 配置即可。 + ### Commit 规范 请确保你的每一个 commit 都能清晰地描述其意图,一个 commit 尽量只有一个意图。