auphofBSF / python-rpi4-workspace

A VSCode workspace that uses a remote docker host on a Raspberry Pi 4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An Remote Development Environment for Python Using Docker Containers and Visual Studio Code

Purpose

  1. To develop Python 3 applications directly on a Raspberry Pi 4 using your own development machine.
  2. To provide a template project to connect remotely to a Raspberry Pi 4 and for building Python Applications for Raspberry Pi 4 using Visual Studio Code, along with the associated tools.
  3. A containerized development environment using the Remote-Containers extension.

Development Machine Requirements

  1. Visual Studio Code
  2. Remote - Containers extension for Visual Studio Code
  3. Docker

Raspberry Pi 4 Requirements

  1. Git
  2. Docker

Installed Frameworks

  1. Docker (Docker In Docker)
  2. Git
  3. Python 3.7
  4. PipEnv
  5. Ruby
  6. Curl, Vim

Developing inside a Container Using VSCode

  1. Clone this repository or copy just the .devcontainer and .vscode folder into your own local git repository folder. You can also run the following script in your terminal.
bash <(wget -qO- https://raw.githubusercontent.com/senglin/python-rpi4-workspace/master/install.sh)
  1. Start VS Code.
  2. Modify .vscode/settings.json with the username and location of the Raspberry Pi 4 device, accessible from your development machine.
  3. In a new window, click on the quick actions Status Bar item in the lower left corner.
  4. Select Remote-Containers:Reopen in Container.
  5. From the menu, select Terminal -> New Terminal. You can now use the installed tools to clone, develop and build in your RPi4 device.
  6. As an example, you can try out this Hello World project for the Raspberry Pi 4.

Debugging Using VSCode

For projects that has Pipfile, you may execute the following line to create a virtual environment

$ pipenv install --dev

Set VS Code to use the created Python Virtual Environment. Use .venv/bin/python which should be in the current project folder.

VS Code will have access to all modules that were installed using pipenv.

Expectation

  1. The container app reuses ssh private key configuration from the host. SSH-AGENT settings are forwarded to the container application.
  2. PIPENV_VENV_IN_PROJECT has been set so that the command pipenv install will install / create virtual environments in the current project folder, rather than the user home folder on the Raspberry Pi.

About

A VSCode workspace that uses a remote docker host on a Raspberry Pi 4


Languages

Language:Dockerfile 80.4%Language:Shell 19.6%