Skip to content

Commit

Permalink
Merge pull request #1532 from jacoverster/basic-devcontainer
Browse files Browse the repository at this point in the history
Adds basic devcontainer for #1057
  • Loading branch information
rodja authored Sep 23, 2023
2 parents dad7729 + 12d5d79 commit c93c9b9
Show file tree
Hide file tree
Showing 7 changed files with 350 additions and 122 deletions.
35 changes: 35 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM python:3.8

ENV POETRY_VERSION=1.6.1 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=false \
POETRY_VIRTUALENVS_CREATE=false \
DEBIAN_FRONTEND=noninteractive \
DISPLAY=:99

# Install packages
RUN apt-get update && apt-get install --no-install-recommends -y \
sudo git build-essential chromium chromium-driver \
&& rm -rf /var/lib/apt/lists/*

# Create remote user
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

ENV PATH="/home/${USERNAME}/.local/bin:${PATH}"
ENV CHROME_BINARY_LOCATION=/usr/bin/chromium

# Install nicegui
RUN pip install -U pip && pip install poetry==$POETRY_VERSION
COPY nicegui pyproject.toml poetry.lock README.md ./
RUN poetry install --all-extras

USER $USERNAME

ENTRYPOINT ["poetry", "run", "python", "-m", "debugpy", "--listen" ,"5678", "main.py"]
39 changes: 39 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "nicegui-dev",
"build": {
"context": "..",
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"cschleiden.vscode-github-actions",
"esbenp.prettier-vscode",
"littlefoxteam.vscode-python-test-adapter",
"ms-python.autopep8",
"ms-python.isort",
"ms-python.mypy-type-checker",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
"samuelcolvin.jinjahtml",
"Vue.volar"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.shell.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash (container default)": {
"path": "/usr/bin/bash",
"overrideName": true
}
}
}
}
}
},
// More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "vscode",
"postCreateCommand": "poetry install --all-extras"
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ tests/media/
venv
.idea
.nicegui/
*.sqlite*
*.sqlite*
.DS_Store
19 changes: 15 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ We're always looking for bug fixes, performance improvements, and new features.

## Setup

To set up a local development environment for NiceGUI, you'll need to have Python 3 and pip installed.
# Dev Container

The simplest way to setup a fully functioning development environment is to start our Dev Container in VS Code:

1. Ensure you have VS Code, Docker and the Remote-Containers extension installed.
2. Open the project root directory in VS Code.
3. Press `F1`, type `Remote-Containers: Open Folder in Container`, and hit enter (or use the bottom-left corner icon in VS Code to reopen in container).
4. Wait until image has been build.
5. Happy coding.

# Locally

To set up a local development environment for NiceGUI, you'll need to have Python 3.8+ and pip installed.

You can then use the following command to install NiceGUI in editable mode:

Expand All @@ -39,10 +51,9 @@ This means we sometimes miss some incompatibilities with older versions.
But these will hopefully be uncovered by the GitHub Actions (see below).
Also we use the 3.8 Docker container described below to verify compatibility in cases of uncertainty.

### Alternative: Docker
### Plain Docker

You can also use Docker for development.
Simply start the development container using the command:
You can also use Docker for development by starting the development container using the command:

```bash
./docker.sh up app
Expand Down
Loading

0 comments on commit c93c9b9

Please sign in to comment.