Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM python:3.13-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
wget \
sudo \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Create vscode user
RUN groupadd --gid 1000 vscode \
&& useradd --uid 1000 --gid vscode --shell /bin/bash --create-home vscode \
&& echo vscode ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/vscode \
&& chmod 0440 /etc/sudoers.d/vscode

# Add vscode user to dialout group for serial port access
RUN usermod -a -G dialout vscode

# Set up working directory
WORKDIR /workspace

# Copy requirements first for better caching
COPY requirements.txt requirements-dev.txt ./

# Install Python dependencies
RUN pip install --upgrade pip \
&& pip install -r requirements.txt \
&& pip install -r requirements-dev.txt

# Switch to vscode user
USER vscode

# Set up shell
RUN echo 'export PATH="/home/vscode/.local/bin:$PATH"' >> /home/vscode/.bashrc
46 changes: 46 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "Python Protocol Gateway Dev Environment",
"dockerComposeFile": "docker-compose.yml",
"service": "dev",
"workspaceFolder": "/workspace",
"shutdownAction": "stopCompose",
"postCreateCommand": "pip install -r requirements-dev.txt",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.flake8",
"charliermarsh.ruff",
"ms-python.pylint",
"ms-vscode.vscode-json",
"ms-python.debugpy",
"GitHub.copilot",
"redhat.vscode-yaml"
],
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.formatting.provider": "none",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.ruff": true
}
},
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.testing.pytestArgs": [
"."
],
"terminal.integrated.defaultProfile.linux": "bash"
}
}
},
"forwardPorts": [1883, 8086],
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached"
],
"remoteUser": "vscode"
}
19 changes: 19 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.8'

services:
dev:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
volumes:
- ..:/workspace:cached
- /var/run/docker.sock:/var/run/docker.sock
devices:
- /dev/ttyUSB0:/dev/ttyUSB0 # Adjust as necessary
privileged: true
network_mode: host
environment:
- PYTHONPATH=/workspace
- PYTHONUNBUFFERED=1
working_dir: /workspace
command: sleep infinity