diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..cd69f6351 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +{ + "name": "moto", + "image": "mcr.microsoft.com/devcontainers/python:0-3.11", + "remoteUser": "root", + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {} + }, + "customizations": { + "vscode": { + "extensions": ["ms-vscode.makefile-tools", "ms-python.python", "ms-python.black-formatter"], + "settings": { + "python.defaultInterpreterPath": "${workspaceFolder}/.venv", + "python.formatting.provider": "none", + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + } + } + } + }, + "postCreateCommand": "python -m venv .venv", + "postStartCommand": ". .venv/bin/activate && make init" +} diff --git a/docs/docs/contributing/installation.rst b/docs/docs/contributing/installation.rst index 73eccfbc2..28f2ddb44 100644 --- a/docs/docs/contributing/installation.rst +++ b/docs/docs/contributing/installation.rst @@ -52,3 +52,31 @@ If black fails, you can run the following command to automatically format the of make format If any of these steps fail, please see our :ref:`contributing faq` or open an issue on Github. + +Development within a Devcontainer +================================== + +Moto is equipped with a `devcontainer.json` for use in VSCode Devcontainers and/or GitHub Codespaces. + +Launching the Devcontainer or Codespace: + + - Configures Docker-in-Docker. + - Sets up a Virtual Environment in `${workspaceFolder}/.venv`. + - Runs `make init`. + +Be patient while the Devcontainer or Codespace launches as dependencies automatically installed. + +Once both `postCreateCommand` and `postStartCommand` have run, open a Terminal session in VSCode and run: + +.. code-block:: bash + + source .venv/bin/activate + +Then standard development on Moto can proceed, for example: + +.. code-block:: bash + + flake8 moto/s3 + black --check moto/s3 tests/test_s3 + pylint tests/test_s3 + pytest -sv tests/test_s3 \ No newline at end of file