✨ 添加多个开发环境的 Docker 配置,包括 Debian、Maven、LaTeX 和 Rust,移除旧的 Rust 配置
This commit is contained in:
parent
3f454b9805
commit
aca5f52bc2
34
general-devcontainer/Containerfile
Normal file
34
general-devcontainer/Containerfile
Normal file
@ -0,0 +1,34 @@
|
||||
FROM docker.io/library/debian:12
|
||||
LABEL maintainer="clzhao98@outlook.com"
|
||||
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources
|
||||
RUN apt-get update && apt-get install -y \
|
||||
openssh-server build-essential cmake ninja-build\
|
||||
git vim-nox curl jq ripgrep bash-completion wget python3&& \
|
||||
apt-get clean &&\
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
ENV http_proxy="socks5://10.177.21.228:10808"
|
||||
ENV https_proxy="socks5://10.177.21.228:10808"
|
||||
ENV no_proxy="localhost, 127.0.0.1, .example.com"
|
||||
|
||||
|
||||
LABEL description="Basic image for develop on debian12"
|
||||
LABEL version="1.0"
|
||||
EXPOSE 1922 80 9000
|
||||
|
||||
|
||||
## 配置 ssh 服务
|
||||
RUN mkdir /var/run/sshd
|
||||
RUN echo "Port 1922" >> /etc/ssh/sshd_config
|
||||
RUN echo "RSAAuthentication yes" >> /etc/ssh/sshd_config
|
||||
RUN echo "root:art@319" | chpasswd \
|
||||
&& sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config \
|
||||
&& sed -i 's/^#\(PermitRootLogin.*\)/\1/' /etc/ssh/sshd_config
|
||||
|
||||
|
||||
ADD start-ssh.sh /start-ssh.sh
|
||||
WORKDIR /workspace
|
||||
|
||||
CMD ["/start-ssh.sh"]
|
||||
#CMD ["service", "ssh", "start" ]
|
||||
#CMD ["/usr/sbin/sshd", "-D", "-p", "1922"]
|
16
general-devcontainer/compose.yaml
Normal file
16
general-devcontainer/compose.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
services:
|
||||
general-debian-dev:
|
||||
image: general-debian-dev:latest
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Containerfile
|
||||
container_name: general-debian-dev
|
||||
hostname: general-devcontainer
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "9090:9090"
|
||||
volumes:
|
||||
- /workspace/projects/:/projects
|
||||
- /workspace:/workspace
|
||||
- /workspace/devcontainer-vols/general-debian-dev-root:/root
|
||||
|
27
general-devcontainer/launch.sh
Normal file
27
general-devcontainer/launch.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
function show_help() {
|
||||
echo "用法: $0 <容器名称> <工作空间路径>"
|
||||
echo
|
||||
echo "参数:"
|
||||
echo " <容器名称> 容器的名称"
|
||||
echo " <工作空间路径> 工作空间的路径"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 参数检查
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
echo "错误: 缺少必要的参数。"
|
||||
show_help
|
||||
fi
|
||||
|
||||
container_name=$1
|
||||
worksapce_path=$2
|
||||
basic_volume_map="-v /workspace/shared-root:/root"
|
||||
basic_port_map="-p 10122:1922"
|
||||
base_cmd="docker run -itd --name ${container_name} --hostname ${container_name} ${basic_port_map} ${basic_volume_map}"
|
||||
image_name="dev-workspace:v2"
|
||||
volume_map=""
|
||||
|
||||
cmd="$base_cmd $volume_map $image_name"
|
||||
echo ">>> $cmd"
|
||||
$cmd
|
7
general-devcontainer/start-ssh.sh
Normal file
7
general-devcontainer/start-ssh.sh
Normal file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
echo "[$LOGTIME] startup run..." >>/root/start_ssh.log
|
||||
service ssh start >>/root/start_ssh.log
|
||||
#service mysql start >>/root/star_mysql.lo
|
||||
bash
|
@ -1,19 +1,15 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
maven-dev-env:
|
||||
image: maven-java21-dev:3.9
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Containerfile
|
||||
container_name: maven-dev-env
|
||||
container_name: maven-devcontainer
|
||||
hostname: maven-devcontainer
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "9090:9090"
|
||||
volumes:
|
||||
- /workspace/projects/:/projects
|
||||
- /workspace:/workspace
|
||||
- /workspace/container-root-volumes/maven-dev-env-root:/root
|
||||
# stdin_open: true # For -i
|
||||
# tty: true # For -t
|
||||
# detach mode is default in compose
|
||||
- /workspace/devcontainer-vols/maven-devcontainer-root:/root
|
@ -1,5 +1,3 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
latex-workspace:
|
||||
# image: texlive/texlive:latest
|
||||
@ -9,7 +7,7 @@ services:
|
||||
dockerfile: Containerfile
|
||||
# image: localhost/latex-env:latest
|
||||
container_name: latex-workspace
|
||||
hostname: latex-env
|
||||
hostname: latex-devcontainer
|
||||
volumes:
|
||||
- /workspace/latex-projects:/workspace
|
||||
- latex-root:/root
|
@ -1,9 +0,0 @@
|
||||
version: '3'
|
||||
services:
|
||||
rust-dev:
|
||||
image: rust-dev
|
||||
volumes:
|
||||
- /workspace/projects:/workspace
|
||||
working_dir: /workspace
|
||||
tty: true
|
||||
stdin_open: true
|
13
rust/compose.yaml
Normal file
13
rust/compose.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
services:
|
||||
rust-dev:
|
||||
image: rust-dev:v1
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Containerfile
|
||||
hostname: rust-devcontainer
|
||||
container_name: rust-dev
|
||||
volumes:
|
||||
- /workspace/projects:/workspace
|
||||
working_dir: /workspace
|
||||
tty: true
|
||||
stdin_open: true
|
Loading…
x
Reference in New Issue
Block a user