瀏覽代碼

Merge branch 'basic-devcontainer' of github.com:jacoverster/nicegui into pr/jacoverster/1532

Rodja Trappe 1 年之前
父節點
當前提交
89c26395bd
共有 2 個文件被更改,包括 20 次插入26 次删除
  1. 8 23
      .devcontainer/Dockerfile
  2. 12 3
      .devcontainer/devcontainer.json

+ 8 - 23
.devcontainer/Dockerfile

@@ -1,49 +1,34 @@
-FROM python:3.8-slim as builder
-
-RUN apt update && apt install -y \
-    gcc \
-    && rm -rf /var/lib/apt/lists/*
-
-RUN python3 -m pip install --upgrade pip
-
-# netifaces needs to be compiled on some platforms (macos ARM for example)
-RUN python3 -m pip install netifaces
-
-FROM python:3.8-slim as devcontainer
+FROM python:3.8-slim
 
 ENV POETRY_VERSION=1.6.1 \
     POETRY_NO_INTERACTION=1 \
     POETRY_VIRTUALENVS_IN_PROJECT=false \
     POETRY_VIRTUALENVS_CREATE=false \
-    POETRY_CACHE_DIR=/tmp/poetry_cache \
     DEBIAN_FRONTEND=noninteractive \
     DISPLAY=:99
 
-# Chrome and chromedriver versions must match
-# See https://chromiumdash.appspot.com/home
-ARG CHROMIUM_VERSION=117.0.5938.62
+# Install packages
+RUN apt-get update && apt-get install --no-install-recommends -y \
+    sudo git gcc chromium chromium-driver \
+    && rm -rf /var/lib/apt/lists/*
 
-# Create remote user and install google chromium and chromium-driver
+# 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 \
-    && apt-get update && apt-get install --no-install-recommends -y \
-    sudo git chromium=${CHROMIUM_VERSION}* chromium-driver=${CHROMIUM_VERSION}* \
     && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
-    && chmod 0440 /etc/sudoers.d/$USERNAME \
-    && rm -rf /var/lib/apt/lists/*
+    && chmod 0440 /etc/sudoers.d/$USERNAME
 
-COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
+ENV PATH="/home/${USERNAME}/.local/bin:${PATH}"
 
 # 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
 
-WORKDIR /workspaces/nicegui
 USER $USERNAME
 
 ENTRYPOINT ["poetry", "run", "python", "-m", "debugpy", "--listen" ,"5678", "main.py"]

+ 12 - 3
.devcontainer/devcontainer.json

@@ -16,10 +16,19 @@
         "samuelcolvin.jinjahtml",
         "ms-python.isort",
         "Vue.volar"
-      ]
+      ],
+      "settings": {
+        "terminal.integrated.shell.linux": "bash",
+        "terminal.integrated.profiles.linux": {
+          "bash (container default)": {
+            "path": "/usr/bin/bash",
+            "overrideName": true
+          }
+        }
+      }
     }
   },
-  "runArgs": ["--net", "host"],
   // More info: https://aka.ms/dev-containers-non-root.
-  "remoteUser": "vscode"
+  "remoteUser": "vscode",
+  "postCreateCommand": "poetry install --all-extras"
 }