Docker Dev Container#

This guide provides step-by-step instructions to set up a Docker Dev Container for developing and running a Dlubal API client. The container is configured to provide a pre-defined Python environment with all necessary tools and dependencies.

Prerequisites#

Before starting, ensure your system meets the following requirements:

  1. Install Docker Desktop to manage and run containerized environments.

    • Verify the installation by running:

      docker --version
      
  2. Install Visual Studio Code as your code editor:

    • Verify the installation by running:

      code --version
      
  3. Install Dev Containers extension in VS Code:

    • Open the Extensions view (Ctrl+Shift+X or Cmd+Shift+X).

    • Search for Dev Containers and click “Install”.

Configuration#

Create a file named devcontainer.json in the .devcontainer folder of your project and use the following configuration:

{
    "name": "Debian",
    "image": "mcr.microsoft.com/devcontainers/base:bookworm",
    "features": {
        "ghcr.io/devcontainers/features/python:1": {
            "installTools": true,
            "version": "3.12"
        }
    },
    "postCreateCommand": "pip install dlubal.api",
    "runArgs": ["--network=host", "--add-host=host.docker.internal:host-gateway"],
    "customizations": {
        "vscode": {
            "extensions": [
                "ms-python.python",
                "ms-python.vscode-pylance",
                "ms-python.autopep8",
                "ms-python.black-formatter",
                "ms-python.debugpy",
                "ms-python.flake8",
                "ms-python.gather",
                "ms-python.mypy-type-checker",
                "ms-python.pylint",
                "zxh404.vscode-proto3"
            ],
            "settings": {
                "python.linting.enabled": true,
                "editor.quickSuggestions": {
                    "comments": false,
                    "strings": false,
                    "other": true
                },
                "files.trimTrailingWhitespace": true,
                "editor.tabSize": 4,
                "editor.insertSpaces": true,
                "python.languageServer": "Pylance",
                "python.analysis.diagnosticSeverityOverrides": {
                    "reportOptionalMemberAccess": "none",
                    "reportGeneralTypeIssues": "none"
                }
            }
        }
    },
    "workspaceFolder": "/workspace",
    "mounts": [
        "source=${localWorkspaceFolder},target=/workspace,type=bind"
    ],
    "forwardPorts": [8081, 9000]
}

Important

You can specify the version of the Dlubal API to be installed by modifying the postCreateCommand in your devcontainer.json file:

"postCreateCommand": "pip install dlubal.api==<version>"

Replace <version> with the desired version number (e.g., 2.9.1)

Using the Dev Container#

Follow these steps to start using the Docker Dev Container:

  1. Open Workspace in VS Code: Launch your project folder in VS Code.

  2. Reopen in Container: Use the command palette (Ctrl+Shift+P or Cmd+Shift+P) and select Dev Containers: Reopen in Container.

  3. Install Dependencies: The container automatically executes the postCreateCommand during setup to install dlubal.api and its dependencies.

  4. Start Development: Begin writing and testing your Dlubal API client in the pre-configured environment.

This setup ensures a consistent and reproducible environment for Dlubal API client development. If you encounter any issues, refer to the troubleshooting section or consult Docker and VS Code documentation.