Skip to content

Commit 40ac07a

Browse files
committed
Add dev container
1 parent 8cb2048 commit 40ac07a

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM python:3.13-slim
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
git \
6+
curl \
7+
wget \
8+
sudo \
9+
build-essential \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Create vscode user
13+
RUN groupadd --gid 1000 vscode \
14+
&& useradd --uid 1000 --gid vscode --shell /bin/bash --create-home vscode \
15+
&& echo vscode ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/vscode \
16+
&& chmod 0440 /etc/sudoers.d/vscode
17+
18+
# Add vscode user to dialout group for serial port access
19+
RUN usermod -a -G dialout vscode
20+
21+
# Set up working directory
22+
WORKDIR /workspace
23+
24+
# Copy requirements first for better caching
25+
COPY requirements.txt requirements-dev.txt ./
26+
27+
# Install Python dependencies
28+
RUN pip install --upgrade pip \
29+
&& pip install -r requirements.txt \
30+
&& pip install -r requirements-dev.txt
31+
32+
# Switch to vscode user
33+
USER vscode
34+
35+
# Set up shell
36+
RUN echo 'export PATH="/home/vscode/.local/bin:$PATH"' >> /home/vscode/.bashrc

.devcontainer/devcontainer.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "Python Protocol Gateway Dev Environment",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "dev",
5+
"workspaceFolder": "/workspace",
6+
"shutdownAction": "stopCompose",
7+
"postCreateCommand": "pip install -r requirements-dev.txt",
8+
"customizations": {
9+
"vscode": {
10+
"extensions": [
11+
"ms-python.python",
12+
"ms-python.flake8",
13+
"charliermarsh.ruff",
14+
"ms-python.pylint",
15+
"ms-vscode.vscode-json",
16+
"ms-python.debugpy",
17+
"GitHub.copilot",
18+
"redhat.vscode-yaml"
19+
],
20+
"settings": {
21+
"python.defaultInterpreterPath": "/usr/local/bin/python",
22+
"python.linting.enabled": true,
23+
"python.linting.flake8Enabled": true,
24+
"python.formatting.provider": "none",
25+
"[python]": {
26+
"editor.defaultFormatter": "charliermarsh.ruff",
27+
"editor.formatOnSave": true,
28+
"editor.codeActionsOnSave": {
29+
"source.fixAll.ruff": true
30+
}
31+
},
32+
"python.testing.pytestEnabled": true,
33+
"python.testing.unittestEnabled": false,
34+
"python.testing.pytestArgs": [
35+
"."
36+
],
37+
"terminal.integrated.defaultProfile.linux": "bash"
38+
}
39+
}
40+
},
41+
"forwardPorts": [1883, 8086],
42+
"mounts": [
43+
"source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached"
44+
],
45+
"remoteUser": "vscode"
46+
}

.devcontainer/docker-compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '3.8'
2+
3+
services:
4+
dev:
5+
build:
6+
context: ..
7+
dockerfile: .devcontainer/Dockerfile
8+
volumes:
9+
- ..:/workspace:cached
10+
- /var/run/docker.sock:/var/run/docker.sock
11+
devices:
12+
- /dev/ttyUSB0:/dev/ttyUSB0
13+
privileged: true
14+
network_mode: host
15+
environment:
16+
- PYTHONPATH=/workspace
17+
- PYTHONUNBUFFERED=1
18+
working_dir: /workspace
19+
command: sleep infinity

0 commit comments

Comments
 (0)