Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 修改 devcontainer,修改文档 #8

Merged
merged 2 commits into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
ARG VARIANT="buster"
FROM mcr.microsoft.com/vscode/devcontainers/rust:0-${VARIANT}

# [Optional] Uncomment this section to install additional packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends libx11-dev libxrandr-dev libx11-xcb-dev
# Setup environment variables
ENV DEBIAN_FRONTEND=noninteractive \
DISPLAY=":1" \
VNC_PORT="5900" \
NOVNC_PORT="6080" \
DISPLAY_WIDTH="1280" \
DISPLAY_HEIGHT="720"

COPY build.sh /tmp/build.sh
COPY docker-init.sh /usr/local/share/docker-init.sh

RUN bash /tmp/build.sh && \
rm /tmp/build.sh && \
chmod +x /usr/local/share/docker-init.sh

ENTRYPOINT [ "/usr/local/share/docker-init.sh" ]
20 changes: 20 additions & 0 deletions .devcontainer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

export DEBIAN_FRONTEND=noninteractive

# Install noVNC X11 packages
apt-get update
apt-get -y install --no-install-recommends \
fluxbox \
xvfb \
x11vnc \
novnc \
libxcb1-dev \
libxrandr-dev

# Configure noVNC
cp /usr/share/novnc/vnc.html /usr/share/novnc/index.html

# Clean
apt-get clean
rm -rf /var/lib/apt/lists/*
85 changes: 41 additions & 44 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
// 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.241.1/containers/rust
{
"name": "Rust",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Use the VARIANT arg to pick a Debian OS version: buster, bullseye
// Use bullseye when on local on arm64/Apple Silicon.
"VARIANT": "buster"
}
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
"name": "Rust",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Use the VARIANT arg to pick a Debian OS version: buster, bullseye
// Use bullseye when on local on arm64/Apple Silicon.
"VARIANT": "buster"
}
},
"overrideCommand": false,
"runArgs": ["--init", "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.executable": "/usr/bin/lldb",
// VS Code don't watch files under ./target
"files.watcherExclude": {
"**/target/**": true
},
"rust-analyzer.checkOnSave.command": "clippy"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vadimcn.vscode-lldb",
"mutantdino.resourcemonitor",
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"serayuzgur.crates"
]
}
},
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.executable": "/usr/bin/lldb",
// VS Code don't watch files under ./target
"files.watcherExclude": {
"**/target/**": true
},
"rust-analyzer.checkOnSave.command": "clippy"
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vadimcn.vscode-lldb",
"mutantdino.resourcemonitor",
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"serayuzgur.crates"
]
}
},

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [6080],

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
12 changes: 12 additions & 0 deletions .devcontainer/docker-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

DISPLAY="${DISPLAY:-:1}"
VNC_PORT="${VNC_PORT:-5900}"
NOVNC_PORT="${NOVNC_PORT:-6080}"
DISPLAY_WIDTH="${DISPLAY_WIDTH:-1280}"
DISPLAY_HEIGHT="${DISPLAY_HEIGHT:-720}"

fluxbox &
Xvfb ${DISPLAY} -screen 0 ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}x24 -dpi 96 -listen tcp -ac &
x11vnc -display ${DISPLAY} -rfbport ${VNC_PORT} -forever &
websockify --web /usr/share/novnc ${NOVNC_PORT} localhost:${VNC_PORT}
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,19 @@ fn main() {
println!("运行耗时: {:?}", start.elapsed());
}
```

## Linux requirements

On Linux, you need to install `libxcb`、`libxrandr`

Debian/Ubuntu:

```sh
apt-get install libxcb1 libxrandr2
```

Alpine:

```sh
apk add libxcb1 libxrandr2
```
6 changes: 0 additions & 6 deletions build.rs

This file was deleted.