mirror of
https://github.com/DefectingCat/dotfiles
synced 2025-07-15 16:51:36 +00:00
update ubuntu dev container
adjust build user
This commit is contained in:
@ -1,9 +1,14 @@
|
||||
FROM ubuntu:noble
|
||||
|
||||
VOLUME [ "/etc/group" ]
|
||||
VOLUME [ "/etc/passwd" ]
|
||||
VOLUME [ "/etc/shadow" ]
|
||||
VOLUME [ "/etc/sudoers.d" ]
|
||||
|
||||
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources \
|
||||
&& sed -i 's@//.*security.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources \
|
||||
&& apt-get update -y \
|
||||
&& apt-get install -y git ninja-build gettext cmake unzip curl build-essential sudo zsh htop \
|
||||
&& apt-get install -y git ninja-build gettext cmake unzip curl build-essential sudo zsh htop vim \
|
||||
# install neovim
|
||||
&& cd /opt && git clone --depth 1 https://gitee.com/mirrors/neovim && cd neovim \
|
||||
&& make CMAKE_BUILD_TYPE=Release \
|
||||
@ -12,8 +17,12 @@ RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ARG USER=xfy
|
||||
RUN useradd --groups sudo --no-create-home --shell /bin/bash ${USER} \
|
||||
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \
|
||||
ARG USER_ID
|
||||
ARG GROUP_ID
|
||||
|
||||
# RUN addgroup --gid $GROUP_ID ${USER} \
|
||||
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID ${USER} \
|
||||
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USER} \
|
||||
&& chmod 0440 /etc/sudoers.d/${USER} \
|
||||
&& usermod -s "$(which zsh)" ${USER}
|
||||
USER ${USER}
|
||||
|
@ -1,5 +1 @@
|
||||
# Dev container with ubuntu
|
||||
|
||||
```shell
|
||||
docker build --progress=plain -t ubuntu-dev -f dockerfiles/ubuntu/Dockerfile .
|
||||
```
|
||||
|
6
dockerfiles/ubuntu/build.sh
Executable file
6
dockerfiles/ubuntu/build.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/env bash
|
||||
|
||||
docker build --progress=plain \
|
||||
--build-arg USER_ID=$(id -u $USER) \
|
||||
--build-arg GROUP_ID=$(id -g $USER) \
|
||||
-t ubuntu-dev -f dockerfiles/ubuntu/Dockerfile .
|
11
dockerfiles/ubuntu/start.sh
Executable file
11
dockerfiles/ubuntu/start.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/env bash
|
||||
|
||||
docker run --rm -it --name=ubuntu-dev \
|
||||
--user $UID:$GID \
|
||||
--workdir="/home/$USER" \
|
||||
--volume="/etc/group:/etc/group:ro" \
|
||||
--volume="/etc/passwd:/etc/passwd:ro" \
|
||||
--volume="/etc/shadow:/etc/shadow:ro" \
|
||||
--volume="/etc/sudoers.d/:/etc/sudoers.d/" \
|
||||
-v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent \
|
||||
ubuntu-dev
|
Reference in New Issue
Block a user