diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 97f48610e8..9168e9d157 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,20 +1,22 @@ -# Rust v1.77 as a base image FROM rust:1.77-slim -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - git openssh-client \ - curl \ - # install python3, jinja2 pyyaml - python3 \ - python3-pip \ +ARG USERNAME=typst-jp +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ + && chsh -s /bin/bash $USERNAME \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + git \ + openssh-client \ + python3 \ + python3-pip \ && python3 -m pip install --break-system-packages jinja2 PyYAML \ - # install nodejs and serve - && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ - && apt-get install -y nodejs \ - && npm install -g serve@14.2.3 \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* \ + && rm -rf /var/lib/apt/lists/* WORKDIR /workspace ENV PATH="/root/.cargo/bin:${PATH}" +USER $USERNAME diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ff9cca255f..a0e89a7183 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,8 +4,9 @@ "dockerfile": "Dockerfile", "context": ".." }, - "forwardPorts": [3000], + "remoteUser": "typst-jp", "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached", "workspaceFolder": "/workspace", - "postStartCommand": "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && npx serve -n ./dist" + "postStartCommand": "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && python3 -m http.server -d dist", + "postCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}" } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b288b27fef..5fee371636 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,7 +4,7 @@ { "label": "gen: typst-jp documentation", "type": "shell", - "command": "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && echo reload or open http://localhost:3000", + "command": "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && echo reload or open http://localhost:8000", "problemMatcher": [] } ]