You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/03/19 12:34:17 UTC
[incubator-opendal] branch main updated: infra: Add odev to simplify contributor's setup (#1687)
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 83e067b9 infra: Add odev to simplify contributor's setup (#1687)
83e067b9 is described below
commit 83e067b991e46d726659aa2c9f41808a5fe0c1dc
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Sun Mar 19 20:34:12 2023 +0800
infra: Add odev to simplify contributor's setup (#1687)
* infra: Add odev to simplify contributor's setup
Signed-off-by: Xuanwo <gi...@xuanwo.io>
* Fix devcontainer
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---------
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
.devcontainer/devcontainer.json | 29 ++++++++++--------
odev | 42 ++++++++++++++++++++++++++
{.devcontainer => scripts/devtools}/Dockerfile | 29 +++++-------------
3 files changed, 65 insertions(+), 35 deletions(-)
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index ce051e08..fd7ffe80 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -1,23 +1,26 @@
{
"name": "OpenDAL",
- "extensions": [
- "cschleiden.vscode-github-actions",
- "rust-lang.rust-analyzer",
- "serayuzgur.crates",
- "vadimcn.vscode-lldb"
- ],
+ "image": "ghcr.io/apache/opendal-devtools:latest",
"mounts": [
"source=${localEnv:HOME}/.cargo/registry,target=/opt/rust/cargo/registry,type=bind,consistency=cached",
- "source=${localEnv:HOME}/.cargo/git,target=/opt/rust/cargo/git,type=bind,consistency=cached"
],
- "dockerFile": "Dockerfile",
"remoteUser": "builder",
"updateRemoteUserUID": true,
"postAttachCommand": "bash",
- "settings": {
- "editor.formatOnSave": true,
- "files.exclude": {
- "**/LICENSE": true
+ "customizations": {
+ "vscode": {
+ "extensions": [
+ "cschleiden.vscode-github-actions",
+ "rust-lang.rust-analyzer",
+ "serayuzgur.crates",
+ "vadimcn.vscode-lldb"
+ ],
+ "settings": {
+ "editor.formatOnSave": true,
+ "files.exclude": {
+ "**/LICENSE": true
+ }
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/odev b/odev
new file mode 100755
index 00000000..57bb8248
--- /dev/null
+++ b/odev
@@ -0,0 +1,42 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+SCRIPT_PATH="$(cd "$(dirname $(realpath "$0"))" >/dev/null 2>&1 && pwd)"
+REL_PATH="$(realpath `pwd` --relative-base=${SCRIPT_PATH})"
+
+CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
+COMMAND="$@"
+
+# NOTE: create with runner user first to avoid permission issues
+mkdir -p "${CARGO_HOME}/registry"
+
+_UID=$(id -u)
+if [[ ${_UID} != "501" ]] && [[ $_UID != "1000" ]] && [[ $_UID != "1001" ]]; then
+ echo "warning: You might encounter permission issues when running this script, since the current uid is ${_UID}, not in [501,1000,1001]." >&2
+ echo ":) feel free to ignore this warning if you do not need sudo." >&2
+fi
+
+exec docker run --rm --tty --net=host \
+ --interactive \
+ --env TERM=xterm-256color \
+ --user $(id -u):$(id -g) \
+ --volume "${CARGO_HOME}/registry:/opt/rust/cargo/registry" \
+ --volume "${SCRIPT_PATH}:/workspace" \
+ --workdir "/workspace/${REL_PATH}" \
+ "ghcr.io/apache/opendal-devtools:latest" \
+ /bin/bash -c "${COMMAND}"
diff --git a/.devcontainer/Dockerfile b/scripts/devtools/Dockerfile
similarity index 66%
rename from .devcontainer/Dockerfile
rename to scripts/devtools/Dockerfile
index 5d753a3c..4f44f278 100644
--- a/.devcontainer/Dockerfile
+++ b/scripts/devtools/Dockerfile
@@ -15,9 +15,10 @@
# specific language governing permissions and limitations
# under the License.
-FROM debian:bullseye
+FROM ubuntu:22.04
ENV TERM xterm-256color
+ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -yq && \
apt-get install -yq locales sudo unzip file curl clang openjdk-11-jdk-headless libssl-dev make git ripgrep && \
@@ -29,12 +30,12 @@ ENV LANGUAGE en_US
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
-
RUN groupdel dialout && groupdel staff && \
groupadd -g 20 staff && groupadd -g 121 docker && \
useradd -u 1000 -g 100 builder && \
- printf "builder ALL=(ALL:ALL) NOPASSWD:ALL\n" > /etc/sudoers.d/opendal && \
- chmod 0440 /etc/sudoers.d/opendal
+ useradd -u 1001 -g 121 runner && \
+ useradd -u 501 -g 20 macos && \
+ printf "builder,runner,macos ALL=(ALL:ALL) NOPASSWD:ALL\n" > /etc/sudoers.d/databend
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable && \
rm -rf /root/.cargo/git && \
@@ -51,24 +52,8 @@ ENV RUSTUP_HOME /opt/rust/rustup
ENV CARGO_HOME /opt/rust/cargo
ENV PATH /opt/rust/cargo/bin:/opt/java/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-VOLUME [ "/workspace", "/opt/rust/cargo/registry", "/opt/rust/cargo/git" ]
-
RUN curl -L --output cargo-binstall.tgz https://github.com/cargo-bins/cargo-binstall/releases/download/v0.19.3/cargo-binstall-x86_64-unknown-linux-gnu.tgz && \
tar xf cargo-binstall*.tgz -C /opt/rust/cargo/bin
-RUN cargo binstall taplo-cli mdbook lsd --no-confirm
-
-RUN curl -qL https://github.com/rui314/mold/releases/download/v1.2.1/mold-1.2.1-$(uname -m)-linux.tar.gz -o /tmp/mold.tar.gz && \
- tar --strip-components=1 -xzf /tmp/mold.tar.gz -C /usr/local && \
- rm -rf /tmp/mold.tar.gz && \
- ln -sf /usr/local/bin/mold /usr/bin/$(uname -m)-linux-gnu-ld
-
-RUN mkdir /home/builder && chown -R builder /home/builder && \
- usermod --shell /bin/bash builder
-
-RUN curl -qL https://github.com/starship/starship/releases/latest/download/starship-$(uname -m)-unknown-linux-musl.tar.gz -o /tmp/starship.tar.gz && \
- tar -xzf /tmp/starship.tar.gz -C /usr/local/bin && \
- rm -rf /tmp/starship.tar.gz && \
- ln -sf /usr/local/bin/starship /usr/bin/starship && \
- echo 'eval "$(starship init bash)"' >> /home/builder/.bashrc
+RUN cargo binstall taplo-cli --no-confirm
-USER builder
\ No newline at end of file
+VOLUME [ "/workspace", "/opt/rust/cargo/registry"]