Skip to content
Open
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
48 changes: 26 additions & 22 deletions docs/doc/dev/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,39 @@ RUN apt-get update \
ca-certificates file g++-multilib libc6:i386 locales \
python3 python3-pip rsync shellcheck \
libopencv-dev libopencv-contrib-dev \
libsdl2-dev \
python3.11 python3.11-venv python3.11-dev \
unzip wget sudo -y \
&& rm /usr/bin/python3 \
&& ln -s /usr/bin/python3.11 /usr/bin/python3 \
&& python3 -m ensurepip --upgrade \
&& apt-get purge -yq \
&& apt-get autoremove -yq --purge \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*

libsdl2-dev wget sudo -y \
&& wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh \
&& bash miniconda.sh -b -p /opt/miniconda \
&& rm miniconda.sh \
&& /opt/miniconda/bin/conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main \
&& /opt/miniconda/bin/conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r \
&& apt-get purge -yq software-properties-common \
&& apt-get autoremove -yq --purge \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*


ENV PATH="/opt/miniconda/bin:$PATH"
RUN conda init bash \
&& conda init zsh
COPY requirements.txt /tmp/requirements.txt
COPY teedoc_requirements.txt /tmp/teedoc_requirements.txt

# RUN python3 -m pip install --upgrade pip
# RUN python3 -m pip install cmake teedoc
# RUN python3 -m pip install -r /tmp/requirements.txt
# RUN python3 -m pip install -r /tmp/teedoc_requirements.txt
RUN conda create -n maixcam2 python=3.13 -y
RUN conda run -n maixcam2 pip install -r /tmp/requirements.txt && \
conda run -n maixcam2 pip install -r /tmp/teedoc_requirements.txt


RUN python3 -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN python3 -m pip install cmake teedoc -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN python3 -m pip install -r /tmp/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN python3 -m pip install -r /tmp/teedoc_requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN conda create -n maixcam python=3.11 -y

RUN ln -s /usr/bin/python3 /usr/bin/python
RUN conda run -n maixcam2 pip install -r /tmp/requirements.txt && \
conda run -n maixcam2 pip install -r /tmp/teedoc_requirements.txt

COPY switch_user.sh /usr/local/bin/switch_user.sh

RUN echo "conda activate maixcam2" >> ~/.bashrc
RUN chmod +x /usr/local/bin/switch_user.sh
WORKDIR /maix
ENTRYPOINT ["/usr/local/bin/switch_user.sh"]


46 changes: 2 additions & 44 deletions docs/doc/dev/docker/switch_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,6 @@

set -e

UID=${UID:-""}
GID=${GID:-""}
USER=${USER:-""}

if [ -z "$USER" ]; then
echo "USER env is required by --env USER=\$USER"
exit 1
fi

if [ -z "$UID" ]; then
echo "UID env is required by --env UID=\`id -u\`"
exit 1
fi

if [ -z "$GID" ]; then
echo "GID env is required by --env GID=\`id -g\`"
exit 1
fi

# if group $USER not exists, add group
if ! grep -q "^$USER:" /etc/group; then
addgroup --gid "$GID" "$USER"
fi

# if user $UID not exists, add user
if ! grep -q "^$USER:" /etc/passwd; then
adduser --gecos "" --uid "$UID" --gid "$GID" --no-create-home --disabled-password "$USER"
mkdir -p /home/"$USER"
cp -r /etc/skel/. /home/"$USER"
# default password is maixcdk
echo "$USER:maixcdk" | chpasswd
usermod -aG sudo "$USER"
fi
chown "$UID":"$GID" /home/"$USER"

# add /maixapp directory and chown to $USER
mkdir -p /maixapp
chown "$UID":"$GID" /maixapp

echo "###########################################################"
echo "##"
Expand All @@ -61,12 +23,8 @@ else
echo "## Please set MAIXCDK_PATH to MaixCDK path in container"
echo "## e.g. add args \`--env MAIXCDK_PATH=/path/to/MaixCDK -v /path/to/MaixCDK:/path/to/MaixCDK\` to docker run command"
fi
echo "## The default password of user ${USER} is 'maixcdk'"
# echo "## The default password of user ${USER} is 'maixcdk'"
echo "###########################################################"
echo ""

cd /home/"$USER"

su "$USER"


bash