|
| 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"] |
0 commit comments