Skip to content

Commit a24878f

Browse files
Setup repo. (#1)
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
1 parent 37657ee commit a24878f

27 files changed

Lines changed: 728 additions & 0 deletions

File tree

.devcontainer/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# DevContainers
2+
3+
- [DevContainers](#devcontainers)
4+
- [Lekiwi-Dev](#lekiwi-dev)
5+
- [Image Details](#image-details)
6+
- [Getting Started](#getting-started)
7+
8+
## Lekiwi-Dev
9+
10+
#### Image Details
11+
12+
* Base Image: `jammy` (ubuntu)
13+
* Rust:
14+
* Installed via rustup.
15+
* The rustc version is configured via `./lekiwi-dev/devcontainer.json` [1]
16+
17+
[1] Override if necessary. At a later date, we might configure the bazel version via a marker file at the project root.
18+
19+
#### Getting Started
20+
21+
Locally:
22+
23+
* [Install VSCode](https://code.visualstudio.com/docs/setup/linux#_debian-and-ubuntu-based-distributions)
24+
* Install [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
25+
* Open the project in VSCode
26+
* CTRL-SHIFT-P &rarr; Reopen in Container
27+
* Open a terminal in the container and run
28+
29+
```
30+
(docker) dev@rust-dev:/workspaces/lekiwi-dora$ cargo build
31+
```
32+
33+
CodeSpaces:
34+
35+
* Go to Codespaces
36+
* Select `New with Options`
37+
* Select `Lekiwi Dev` from the `Dev Container Configuration`
38+
39+
* Open a terminal in the container and run
40+
41+
```
42+
@<github-username> ➜ /workspaces/rnd_lekiwi (main) $ cargo build
43+
```
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
################################################################################
2+
# Base Image
3+
################################################################################
4+
5+
ARG BASE_IMAGE=jammy
6+
FROM mcr.microsoft.com/devcontainers/base:${BASE_IMAGE}
7+
8+
################################################################################
9+
# Configuration
10+
################################################################################
11+
12+
ARG RUST_VERSION=1.86.0
13+
14+
################################################################################
15+
# User 'dev'
16+
################################################################################
17+
18+
ARG USERNAME=dev
19+
ARG UID=1000
20+
ARG GID=1000
21+
22+
RUN groupadd -o --gid ${GID} ${USERNAME}
23+
RUN useradd -o --uid ${UID} --gid ${GID} -s "/bin/bash" -m ${USERNAME} && \
24+
apt-get install -y sudo && \
25+
echo "${USERNAME} ALL=NOPASSWD: ALL" > /etc/sudoers.d/${USERNAME} && \
26+
chmod 0440 /etc/sudoers.d/${USERNAME}
27+
28+
RUN usermod -a -G dialout $USERNAME
29+
30+
COPY .devcontainer/lekiwi-dev/dev.bashrc /home/${USERNAME}/.bashrc.d/dev.bashrc
31+
RUN echo "source /home/${USERNAME}/.bashrc.d/dev.bashrc" >> /home/${USERNAME}/.bashrc
32+
33+
RUN mkdir -p /home/${USERNAME}/.local/share/bash-completion/completions/ && \
34+
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.local
35+
36+
################################################################################
37+
# Tools & Utilities
38+
################################################################################
39+
40+
RUN apt-get update && apt-get install -y --no-install-recommends \
41+
# development
42+
curl \
43+
bash \
44+
bash-completion \
45+
g++ \
46+
gcc \
47+
git \
48+
graphviz \
49+
make \
50+
pkg-config \
51+
ssh \
52+
wget \
53+
vim \
54+
less \
55+
zip \
56+
# python
57+
python3-dev \
58+
python3-pip \
59+
# linux
60+
libudev-dev \
61+
# cv2 deps
62+
ffmpeg libsm6 libxext6 \
63+
# gl deps
64+
mesa-utils libvulkan1 libvulkan-dev vulkan-tools libegl1 libgles2 \
65+
# Rerun specifically needs libxkbcommon-dev, libxkbcommon-x11-0
66+
libasound2-dev libudev-dev libx11-dev libxinerama-dev libxkbcommon-dev libxkbcommon-x11-0 x11-apps x11-xserver-utils \
67+
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
68+
69+
RUN pip install \
70+
pre-commit==2.20.0
71+
72+
################################################################################
73+
# Installs Rust toolchain for specified rust version (RUST_VERSION).
74+
# Installs Rust autocompletion for bash.
75+
################################################################################
76+
77+
ENV RUSTUP_HOME="/opt/rustup"
78+
ENV CARGO_HOME="/opt/cargo"
79+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${RUST_VERSION} \
80+
&& . "${CARGO_HOME}/env" \
81+
&& rustup component add clippy \
82+
&& rustup component add rustfmt \
83+
&& cargo install cargo-deb \
84+
&& cargo install cargo-expand \
85+
&& cargo install cargo-rdme \
86+
&& rustup target add x86_64-unknown-linux-gnu \
87+
&& rustup completions bash cargo >> /home/${USERNAME}/.local/share/bash-completion/completions/cargo \
88+
&& echo "export RUSTUP_HOME=${RUSTUP_HOME}" >> /etc/profile \
89+
&& echo "export PATH=${CARGO_HOME}/bin:\${PATH}" >> /etc/profile
90+
ENV PATH="$CARGO_HOME/bin/:$PATH"
91+
92+
# The previous command roots permissions in ${CARGO_HOME} and ${RUSTUP_HOME}.
93+
# Establish wide permissions for user 'dev'. This step takes several minutes.
94+
95+
RUN find ${CARGO_HOME} -type d -exec chmod 777 {} + && \
96+
find ${CARGO_HOME} -type f -exec chmod a+rw {} + && \
97+
find ${RUSTUP_HOME} -type d -exec chmod 777 {} + && \
98+
find ${RUSTUP_HOME} -type f -exec chmod a+rw {} +
99+
100+
##############################################################################
101+
# Final configuration
102+
##############################################################################
103+
104+
# Update pip: Default pip version(22.) presents issues with
105+
# installing packages without setupt.py file:
106+
# See https://stackoverflow.com/questions/78034052/unknown-project-name-and-version-number-for-my-own-pip-package
107+
RUN pip install --upgrade pip
108+
109+
# Install desired cargo bin crates
110+
RUN cargo install \
111+
# Depending on binary crates doesn't allow you to use them from cli.
112+
# https://github.com/rust-lang/cargo/issues/2267
113+
dora-cli --version 0.3.12
114+
115+
# The previous commands roots permissions in ${CARGO_HOME} and ${RUSTUP_HOME}.
116+
# Establish wide permissions for user 'dev'. This step takes several minutes.
117+
RUN find ${CARGO_HOME} -type d -exec chmod 777 {} + && \
118+
find ${CARGO_HOME} -type f -exec chmod a+rw {} + && \
119+
find ${RUSTUP_HOME} -type d -exec chmod 777 {} + && \
120+
find ${RUSTUP_HOME} -type f -exec chmod a+rw {} +
121+
122+
USER ${USERNAME}
123+
124+
################################################################################
125+
# Python dev install
126+
################################################################################
127+
128+
# Install uv package manager: https://github.com/astral-sh/uv
129+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
130+
131+
################################################################################
132+
# NVIDIA
133+
################################################################################
134+
135+
ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
136+
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics,display,video,utility,compute
137+
138+
################################################################################
139+
# Login Shell
140+
################################################################################
141+
142+
ENV TERM xterm-256color
143+
ENTRYPOINT ["/bin/bash", "--login", "-i"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# parsing Git information
2+
parse_git_branch() {
3+
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
4+
}
5+
6+
unstaged() {
7+
if [[ $(git status -s 2> /dev/null | wc -c) != 0 ]]; then echo " +"; fi
8+
}
9+
10+
export PS1='\[\033[01;36m\](docker)\[\033[00m\] \[\033[01;32m\]\u@lekiwi-${USER}\[\033[00m\]:\[\033[01;34m\]\w\[\033[33m\]$(parse_git_branch)$(unstaged)\[\033[00m\] \$ '
11+
alias ll='ls --color=auto -alFNh'
12+
alias ls='ls --color=auto -Nh'
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "lekiwi-dora dev",
3+
// This is a workaround for the limitation of not being able to run $(id -u) in devcontainer.json
4+
// so as to pass it to the build context via "build" dictionary.
5+
// We are here using initializeCommand to run a script that builds the image with the correct UID and GID.
6+
"initializeCommand": [".devcontainer/lekiwi-dev/initialize_command.sh"],
7+
"image": "lekiwi-dora-dev-container",
8+
"containerEnv": {
9+
"DISPLAY": "${localEnv:DISPLAY}",
10+
// Guarantee that the uv cache is in the same filesystem as the workspace
11+
// to avoid copies.
12+
"UV_CACHE_DIR": "${containerWorkspaceFolder}/.uv_cache"
13+
},
14+
"mounts": [
15+
"type=bind,source=/dev,target=/dev",
16+
"type=bind,source=/tmp/.X11-unix,target=/tmp/.X11-unix"
17+
],
18+
"remoteUser": "dev",
19+
"customizations": {
20+
"vscode": {
21+
"extensions": [
22+
"rust-lang.rust-analyzer",
23+
"bierner.github-markdown-preview",
24+
"bierner.markdown-preview-github-styles",
25+
"github.vscode-github-actions",
26+
"pbkit.vscode-pbkit",
27+
"streetsidesoftware.code-spell-checker",
28+
"yzhang.markdown-all-in-one",
29+
"tamasfe.even-better-toml",
30+
"ritwickdey.liveserver",
31+
"ms-python.python",
32+
"ms-python.vscode-pylance"
33+
]
34+
}
35+
},
36+
// TODO(francocipollone): Create another devcontainer profile for non-GPU-enabled development
37+
"runArgs": [
38+
"--privileged", // Required for /dev access
39+
"--network=host",
40+
"--runtime=nvidia", // Use NVIDIA runtime for GPU access
41+
"--gpus=all", // Use all available GPUs
42+
"--name=lekiwi-dora"
43+
]
44+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
export UID=$(id -u)
4+
export GID=$(id -g)
5+
6+
docker build -t lekiwi-dora-dev-container -f .devcontainer/lekiwi-dev/Dockerfile \
7+
--build-arg UID=$UID \
8+
--build-arg GID=$GID \
9+
.

.github/workflows/ci.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
# Cancel previously running PR jobs
11+
concurrency:
12+
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
13+
cancel-in-progress: true
14+
15+
env:
16+
CARGO_TERM_COLOR: always
17+
18+
jobs:
19+
lint:
20+
name: Lint
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Install prerequisites
25+
uses: awalsh128/cache-apt-pkgs-action@latest
26+
with:
27+
packages: libudev-dev
28+
version: 1.0
29+
- name: Install pre-commit
30+
run: |
31+
python3 -m pip install --upgrade pip
32+
python3 -m pip install pre-commit
33+
- name: Install pre-commit hooks
34+
run: pre-commit install
35+
- name: Indicate safe directory
36+
## See https://github.com/actions/checkout/issues/363
37+
run: git config --global --add safe.directory $(realpath .)
38+
- name: Rust cache
39+
uses: Swatinem/rust-cache@v2
40+
- run: pre-commit run --all-files --verbose --show-diff-on-failure
41+
42+
build_and_test_cargo:
43+
name: Cargo Build & Test
44+
needs: lint
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v4
48+
- name: Install prerequisites
49+
uses: awalsh128/cache-apt-pkgs-action@latest
50+
with:
51+
packages: libudev-dev
52+
version: 1.0
53+
- name: Rust cache
54+
uses: Swatinem/rust-cache@v2
55+
- name: Cargo build
56+
run: cargo build --workspace --all-targets
57+
- name: Cargo test
58+
run: cargo test --workspace --all-targets
59+
60+
build_and_test_uv:
61+
name: UV Build & Test
62+
needs: lint
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
- name: Install uv package manager
67+
run: |
68+
python3 -m pip install --upgrade pip
69+
python3 -m pip install uv
70+
- name: UV build
71+
run: uv build --all-packages
72+
- name: pytest
73+
run: uv run --all-packages pytest

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
debug/
4+
target/
5+
6+
# These are backup files generated by rustfmt
7+
**/*.rs.bk
8+
9+
# Generated by dora node
10+
out
11+
12+
# Generated by dora graph command
13+
*-graph.html
14+
15+
# Folder for the user to test stuff
16+
sandbox
17+
18+
# datasets of yolo
19+
*.pt
20+
21+
# Python compiled files
22+
dist
23+
*.egg-info
24+
.venv
25+
__pycache__
26+
*.pyc
27+
*.ruff_cache
28+
*.pytest_cache
29+
30+
# MuJoCo outputs
31+
*.mp4
32+
33+
# uv cache
34+
.uv_cache

0 commit comments

Comments
 (0)