generated from Tom-Notch/Repository-Template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
2,028 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# .env | ||
XSOCK=/tmp/.X11-unix | ||
XAUTH=/tmp/.docker.xauth | ||
AVAILABLE_CORES=$(($(nproc) - 1)) | ||
|
||
DOCKER_USER=todo-docker-user | ||
IMAGE_NAME=todo-image-name | ||
IMAGE_TAG=latest | ||
|
||
CONTAINER_NAME=${IMAGE_NAME} | ||
CONTAINER_HOME_FOLDER=/root | ||
CODE_FOLDER=${IMAGE_NAME} | ||
|
||
HOST_UID=$(id -u) | ||
HOST_GID=$(id -g) | ||
HOSTNAME=${HOSTNAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,7 +216,7 @@ celerybeat.pid | |
*.sage.py | ||
|
||
# Environments | ||
.env | ||
# .env | ||
.venv | ||
env/ | ||
venv/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
version: "3" | ||
|
||
services: | ||
default: | ||
build: | ||
dockerfile: ./docker/${IMAGE_TAG}/Dockerfile | ||
x-bake: | ||
contexts: | ||
home-folder-config: ./docker/build-context/home-folder-config | ||
platforms: | ||
- linux/amd64 # for PC | ||
- linux/arm64 # for arm64 platforms | ||
privileged: true | ||
tags: | ||
- ${DOCKER_USER}/${IMAGE_NAME}:${IMAGE_TAG} | ||
image: ${DOCKER_USER}/${IMAGE_NAME}:${IMAGE_TAG} | ||
pull_policy: missing | ||
container_name: ${CONTAINER_NAME} | ||
privileged: true | ||
hostname: ${HOSTNAME} | ||
network_mode: host | ||
ipc: host | ||
pid: host | ||
ulimits: | ||
core: -1 | ||
group_add: | ||
- video | ||
- audio | ||
environment: # -e | ||
DISPLAY: ${DISPLAY} | ||
QT_X11_NO_MITSHM: 1 | ||
XAUTHORITY: ${XAUTH} | ||
volumes: # -v | ||
- /var/lib/systemd/coredump/:/cores | ||
- /tmp/.X11-unix/:/tmp/.X11-unix/:rw | ||
- ${XAUTH}:${XAUTH} | ||
- .:${CONTAINER_HOME_FOLDER}/${CODE_FOLDER} | ||
working_dir: ${CONTAINER_HOME_FOLDER}/${CODE_FOLDER} | ||
stdin_open: true # for -it | ||
tty: true # for -it | ||
# command: /bin/zsh |
1,660 changes: 1,660 additions & 0 deletions
1,660
docker/build-context/home-folder-config/.p10k.zsh
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
termcapinfo xterm* ti@:te@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
set -g mouse on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# Check if the HOST_UID and HOST_GID are specified | ||
if [ -n "${HOST_UID+x}" ] && [ -n "${HOST_GID+x}" ]; then | ||
# Change 'myuser' UID and GID to match the host user's UID and GID | ||
sudo usermod -u "$HOST_UID" "$(whoami)" | ||
sudo groupmod -g "$HOST_GID" "$(whoami)" | ||
# Ensure ownership of home directory is reset to 'myuser' after UID and GID change | ||
chown -R "$(whoami)":"$(whoami)" /home/"$(whoami)" | ||
fi | ||
|
||
# Switch to 'myuser' | ||
su -c "$(whoami)" | ||
|
||
# Run the main command with exec to replace the current process (bash) with the given command | ||
# This is important because of how signals are handled (https://hynek.me/articles/docker-signals/) | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
user: camera-driver | ||
group: camera-driver | ||
paths: | ||
- /home/camera-driver/.oh-my-zsh | ||
- /home/camera-driver/.zshrc | ||
- /home/camera-driver/.bashrc | ||
- /tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Do not add --platform=linux/blabla since this is intended for multiplatform builds | ||
FROM tomnotch/bipvrobotics-base-image:latest | ||
ENV HOME_FOLDER=/root | ||
WORKDIR $HOME_FOLDER/ | ||
|
||
# Fix apt install stuck problem | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections | ||
|
||
# update all obsolete packages to latest, install sudo, and cleanup | ||
RUN apt update -o Acquire::Check-Valid-Until=false -o Acquire::AllowInsecureRepositories=true -o Acquire::AllowDowngradeToInsecureRepositories=true && \ | ||
apt full-upgrade -y && \ | ||
apt install -y sudo ca-certificates && \ | ||
apt autoremove -y && \ | ||
apt autoclean -y | ||
|
||
# # Add a new group and user | ||
# RUN addgroup --gid 1000 $USER && \ | ||
# adduser --uid 1000 --ingroup $USER --home $HOME_FOLDER --shell /bin/zsh --disabled-password --gecos "" $USER && \ | ||
# echo "$USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
||
# # Fix UID/GID when mounting from host using this: https://github.com/boxboat/fixuid | ||
# RUN curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.6.0/fixuid-0.6.0-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - && \ | ||
# chown root:root /usr/local/bin/fixuid && \ | ||
# chmod 4755 /usr/local/bin/fixuid && \ | ||
# mkdir -p /etc/fixuid | ||
|
||
# # Switch to the new user | ||
# USER $USER:$USER | ||
|
||
#! Install OpenCV 4.2.0 with QUIRC support from source | ||
ENV OPENCV_VERSION=4.2.0 | ||
RUN pip3 uninstall -y opencv && \ | ||
apt install -y --no-install-recommends libavcodec-dev libavformat-dev libswscale-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libgtk-3-dev libpng-dev libjpeg-dev && \ | ||
git clone --depth 1 --recursive https://github.com/opencv/opencv.git $HOME_FOLDER/opencv -b $OPENCV_VERSION && \ | ||
# follow the error information,replace all the “ipcp-unit-growth” with “ipa-cp-unit-growth” in 3rdparty/carotene/CMakeLists.txt and 3rdparty/carotene/hal/CMakeLists.txt | ||
perl -pi -e 's/ipcp-unit-growth/ipa-cp-unit-growth/g' $HOME_FOLDER/opencv/3rdparty/carotene/CMakeLists.txt $HOME_FOLDER/opencv/3rdparty/carotene/hal/CMakeLists.txt && \ | ||
git clone --depth 1 --recursive https://github.com/opencv/opencv_contrib.git $HOME_FOLDER/opencv_contrib -b $OPENCV_VERSION && \ | ||
mkdir -p $HOME_FOLDER/opencv/build && \ | ||
cd $HOME_FOLDER/opencv/build && \ | ||
cmake \ | ||
-D CMAKE_CXX_STANDARD=20 \ | ||
-D EIGEN_INCLUDE_PATH=/usr/include/eigen3 \ | ||
-D OPENCV_GENERATE_PKGCONFIG=ON \ | ||
-D BUILD_opencv_python3=ON \ | ||
-D OPENCV_PYTHON3_INSTALL_PATH=/usr/local/lib/python3.8/dist-packages \ | ||
# -D OPENCV_ENABLE_NONFREE=ON \ | ||
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \ | ||
# -D WITH_LAPACK=ON \ | ||
-D WITH_GTK=ON \ | ||
-D WITH_TBB=ON \ | ||
# -D WITH_QUIRC=ON \ | ||
-D WITH_GSTREAMER=ON \ | ||
-D WITH_V4L=ON \ | ||
# -D WITH_OPENGL=ON \ | ||
-D BUILD_TESTS=OFF \ | ||
-D BUILD_PERF_TESTS=OFF \ | ||
-D BUILD_EXAMPLES=OFF \ | ||
-D CMAKE_BUILD_TYPE=RELEASE \ | ||
-D CMAKE_INSTALL_PREFIX=/usr/local .. && \ | ||
make install -j$(($(nproc)-1)) && \ | ||
echo "export OpenCV_DIR=/usr/local/lib/cmake/opencv4/" >> ${HOME_FOLDER}/.zshrc && \ | ||
echo "export OpenCV_DIR=/usr/local/lib/cmake/opencv4/" >> ${HOME_FOLDER}/.bashrc && \ | ||
rm -rf $HOME_FOLDER/opencv && \ | ||
rm -rf $HOME_FOLDER/opencv_contrib | ||
|
||
# end of sudo apt installs | ||
RUN apt full-upgrade -y && \ | ||
apt autoremove -y && \ | ||
apt autoclean -y && \ | ||
apt clean -y && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set the default shell to zsh | ||
SHELL [ "/bin/zsh", "-c" ] | ||
|
||
# # move fixuid config | ||
# RUN mv $HOME_FOLDER/fixuid-config.yml /etc/fixuid/config.yml | ||
|
||
# Entrypoint command | ||
# ENTRYPOINT [ "/bin/sh" , "-c", "fixuid; /bin/zsh" ] | ||
ENTRYPOINT [ "/bin/zsh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Created on Wed Sep 04 2024 18:04:23 | ||
# Author: Mukai (Tom Notch) Yu | ||
# Email: [email protected] | ||
# Affiliation: Carnegie Mellon University, Robotics Institute | ||
# | ||
# Copyright Ⓒ 2024 Mukai (Tom Notch) Yu | ||
# | ||
|
||
. "$(dirname "$0")"/variables.sh | ||
|
||
# Determine the local platform | ||
if [[ "$(uname -m)" == "x86_64" ]]; then | ||
LOCAL_PLATFORM="linux/amd64" | ||
elif [[ "$(uname -m)" == "arm64" ]]; then | ||
LOCAL_PLATFORM="linux/arm64" | ||
else | ||
echo "Unsupported local platform: $(uname -m)" | ||
exit 1 | ||
fi | ||
|
||
# Desired builder name | ||
BUILDER_NAME="multi-platform" | ||
|
||
# Check if the builder already exists | ||
if ! docker buildx ls | grep -q "^${BUILDER_NAME} "; then | ||
echo "Creating Docker Buildx builder '${BUILDER_NAME}'..." | ||
docker buildx create \ | ||
--name "${BUILDER_NAME}" \ | ||
--use --platform linux/amd64,linux/arm64 \ | ||
--driver docker-container | ||
else | ||
echo "Docker Buildx builder '${BUILDER_NAME}' already exists." | ||
fi | ||
|
||
# Build the Docker image for only the local platform, push.sh will push multi-platform version | ||
docker buildx bake --file "$(dirname "$0")"/../docker-compose.yml --load --set "*.platform=$LOCAL_PLATFORM" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Created on Wed Sep 04 2024 18:04:42 | ||
# Author: Mukai (Tom Notch) Yu | ||
# Email: [email protected] | ||
# Affiliation: Carnegie Mellon University, Robotics Institute | ||
# | ||
# Copyright Ⓒ 2024 Mukai (Tom Notch) Yu | ||
# | ||
|
||
. "$(dirname "$0")"/variables.sh | ||
|
||
docker exec --privileged -it "$CONTAINER_NAME" pkill -f zsh | ||
|
||
docker rm -f "$CONTAINER_NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Created on Wed Sep 04 2024 18:04:36 | ||
# Author: Mukai (Tom Notch) Yu | ||
# Email: [email protected] | ||
# Affiliation: Carnegie Mellon University, Robotics Institute | ||
# | ||
# Copyright Ⓒ 2024 Mukai (Tom Notch) Yu | ||
# | ||
|
||
. "$(dirname "$0")"/variables.sh | ||
|
||
echo "Removing all containers" | ||
|
||
for id in $(docker ps -aq); do | ||
echo "Removing container $id" | ||
docker rm -f "$id" | ||
done | ||
|
||
echo "Done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Created on Wed Sep 04 2024 18:04:49 | ||
# Author: Mukai (Tom Notch) Yu | ||
# Email: [email protected] | ||
# Affiliation: Carnegie Mellon University, Robotics Institute | ||
# | ||
# Copyright Ⓒ 2024 Mukai (Tom Notch) Yu | ||
# | ||
|
||
. "$(dirname "$0")"/variables.sh | ||
|
||
docker pull "$DOCKER_USER"/"$IMAGE_NAME":"$IMAGE_TAG" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Created on Wed Sep 04 2024 18:04:56 | ||
# Author: Mukai (Tom Notch) Yu | ||
# Email: [email protected] | ||
# Affiliation: Carnegie Mellon University, Robotics Institute | ||
# | ||
# Copyright Ⓒ 2024 Mukai (Tom Notch) Yu | ||
# | ||
|
||
. "$(dirname "$0")"/variables.sh | ||
|
||
# docker push "$DOCKER_USER"/"$IMAGE_NAME":"$IMAGE_TAG" | ||
|
||
docker buildx bake --file "$(dirname "$0")"/../docker-compose.yml --push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Created on Wed Sep 04 2024 18:05:06 | ||
# Author: Mukai (Tom Notch) Yu | ||
# Email: [email protected] | ||
# Affiliation: Carnegie Mellon University, Robotics Institute | ||
# | ||
# Copyright Ⓒ 2024 Mukai (Tom Notch) Yu | ||
# | ||
|
||
. "$(dirname "$0")"/variables.sh | ||
|
||
xhost +local:* | ||
|
||
if [ ! -f "$XAUTH" ]; then | ||
touch "$XAUTH" | ||
xauth_list=$(xauth nlist "$DISPLAY" | sed -e 's/^..../ffff/') | ||
if [ -n "$xauth_list" ]; then | ||
echo "$xauth_list" | xauth -f "$XAUTH" nmerge - | ||
fi | ||
chmod a+r "$XAUTH" | ||
fi | ||
|
||
if [ "$(docker ps -a -q -f name="$CONTAINER_NAME")" ]; then | ||
echo "A container with name ""$CONTAINER_NAME"" is running, force removing it" | ||
docker rm -f "$CONTAINER_NAME" | ||
echo "Done" | ||
fi | ||
|
||
docker run \ | ||
--name "$CONTAINER_NAME" \ | ||
--hostname "$(hostname)" \ | ||
--privileged \ | ||
--cpus "$AVAILABLE_CORES" \ | ||
--network host \ | ||
--ipc host \ | ||
--pid host \ | ||
--ulimit core=-1 \ | ||
--group-add audio \ | ||
--group-add video \ | ||
--volume=":" \ | ||
-e DISPLAY="$DISPLAY" \ | ||
-e XAUTHORITY="$XAUTH" \ | ||
-e QT_X11_NO_MITSHM=1 \ | ||
-v /var/lib/systemd/coredump/:/cores \ | ||
-v "$XSOCK":"$XSOCK" \ | ||
-v "$XAUTH":"$XAUTH" \ | ||
-v "$HOME"/.Xauthority:"$CONTAINER_HOME_FOLDER"/.Xauthority:rw \ | ||
-v "$(dirname "$0")"/..:"$CONTAINER_HOME_FOLDER"/"$CODE_FOLDER" \ | ||
-w "$CONTAINER_HOME_FOLDER"/"$CODE_FOLDER" \ | ||
--rm \ | ||
-itd "$DOCKER_USER"/"$IMAGE_NAME":"$IMAGE_TAG" |
Oops, something went wrong.