Configure devcontainer for python

This commit is contained in:
Philipp Grathwohl 2022-02-16 12:51:09 +01:00
parent c781f9cd2f
commit 9366c18a38
8 changed files with 132 additions and 3 deletions

14
.devcontainer/Dockerfile Normal file
View file

@ -0,0 +1,14 @@
ARG VARIANT=3-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel
# Install craftbeerpi requirements for better caching
COPY ./requirements.txt /workspace/requirements.txt
RUN pip3 install --no-cache-dir -r /workspace/requirements.txt
# Install current version of cbpi-ui
RUN mkdir /opt/downloads \
&& curl https://github.com/avollkopf/craftbeerpi4-ui/archive/main.zip -L -o /opt/downloads/cbpi-ui.zip \
&& pip3 install --no-cache-dir /opt/downloads/cbpi-ui.zip \
&& rm -rf /opt/downloads

View file

@ -0,0 +1,48 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/docker-existing-docker-compose
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
{
"name": "CraftBeerPi4 Development Container",
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"docker-compose.dev.yml"
],
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "craftbeerpi4-development",
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspace",
// Set *default* container specific settings.json values on container create.
"settings": {
//"terminal.integrated.shell.linux": null
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-azuretools.vscode-docker",
"editorconfig.editorconfig",
"eamodio.gitlens"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [80],
// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
"shutdownAction": "stopCompose",
// Uncomment the next line to run commands after the container is created - for example installing curl.
//"postCreateCommand": "pip3 install -r ./requirements.txt",
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}

View file

@ -0,0 +1,30 @@
version: '3.4'
services:
mqtt:
image: eclipse-mosquitto:2
volumes:
- "./mosquitto/config:/mosquitto/config"
restart: unless-stopped
craftbeerpi4-development:
build:
context: ../
dockerfile: .devcontainer/Dockerfile
command: /bin/sh -c "while sleep 1000; do :; done"
user: vscode
depends_on:
- mqtt
volumes:
# Update this to wherever you want VS Code to mount the folder of your project
- ../:/workspace:cached
mqtt-explorer:
image: smeagolworms4/mqtt-explorer
environment:
HTTP_PORT: 4000
CONFIG_PATH: /mqtt-explorer/config
volumes:
- "./mqtt-explorer/config:/mqtt-explorer/config"
depends_on:
- mqtt
restart: unless-stopped

1
.gitignore vendored
View file

@ -14,6 +14,5 @@ node_modules
.vscode
.venv*
.DS_Store
.vscode/
config/*
logs/

16
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,16 @@
{
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Run CraftBeerPi4",
"type": "python",
"request": "launch",
"module": "run",
"args": ["--config-folder-path=./.devcontainer/cbpi-dev-config", "start"]
}
]
}

8
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,8 @@
{
"python.pythonPath": "/bin/python3",
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}

View file

@ -21,7 +21,19 @@ in the documentation, that can be found here: [gitbook.io](https://openbrewing.g
Plugins extend the base functionality of CraftBeerPi 4.
You can find a list of available plugins [here](https://openbrewing.gitbook.io/craftbeerpi4_support/master/plugin-installation#plugin-list).
## 🧑‍🤝‍🧑 Contributers
## 🧑‍🤝‍🧑 Contribute
You want to help develop CraftBeerPi4? To get you quickly stated, this repository comes with a preconfigured
development environment. To be able to use this environment you need 2 things installed on your computer:
- docker
- visual studio code (vscode)
To start developing clone this repository, open the folder in vscode and use the _development container_ feature. The command is called _Reopen in container_. Please note that this quick start setup does not work if you want to develop directly on a 32bit raspberry pi os because docker is only available for 64bit arm plattform. Please use the regular development setup for that.
For a more detailed description of a development setup without the _development container_ feature see the documentation page:
[gitbook.io](https://openbrewing.gitbook.io/craftbeerpi4_support/)
### Contributors
Thanks to all the people who have contributed
[![contributors](https://contributors-img.web.app/image?repo=craftbeerpi/craftbeerpi4)](https://github.com/craftbeerpi/craftbeerpi4/graphs/contributors)

View file

@ -21,4 +21,6 @@ asyncio-mqtt
psutil==5.9.0
zipp>=0.5
PyInquirer==1.0.3
colorama==0.4.4
colorama==0.4.4
pytest-aiohttp
coverage==6.3.1