Compare commits

...

1 Commits

Author SHA1 Message Date
f7cb2a948c 开发容器启动配置 2026-03-01 11:30:21 +00:00
5 changed files with 84 additions and 0 deletions

1
.env Normal file
View File

@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=devcontainers

1
authorized_keys Normal file
View File

@@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEXPddCUCbsAShg6+21q/MIvFM27xlqVr+Yg3MoHqUZp

13
combined-init.sh Normal file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
set -eux
/usr/local/share/desktop-init.sh echo "Desktop initialization complete"
/usr/local/share/docker-init.sh echo "Docker initialization complete"
/usr/local/share/ssh-init.sh echo "SSH initialization complete"
# exposed ports
# 5901 VNC
# 6080 noVNC
# 2222 SSH
exec "$@"

33
docker-compose.yml Normal file
View File

@@ -0,0 +1,33 @@
services:
dev-server:
image: registry.yqxpro.com/devcontainers/universal-base:latest
privileged: true
restart: always
ports:
- 2222:2222
- 6080:6080
volumes:
# environment
- ${PWD}/authorized_keys:/home/codespace/.ssh/authorized_keys
- ${PWD}/combined-init.sh:/usr/local/share/combined-init.sh
- ${PWD}/once-init.sh:/usr/local/share/once-init.sh
# workspace
- workspace:/workspace
# cache
- maven-cache:/home/codespace/.m2/repository
- docker-cache:/var/lib/docker
- apt-cache:/var/cache/apt
- vscode-cache:/home/codespace/.vscode-server
- zed-cache:/home/codespace/.zed_server
entrypoint: /usr/local/share/combined-init.sh
command: sleep infinity
volumes:
workspace:
name: dev-server-workspace
external: true
maven-cache:
docker-cache:
apt-cache:
vscode-cache:
zed-cache:

36
once-init.sh Normal file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
set -eux
# use VNC DISPLAY by default
echo "export DISPLAY=:1.0" >> /etc/profile.d/00-restore-env.sh
mkdir -pv /home/codespace/.cargo
cat > /home/codespace/.cargo/config.toml << EOF
[source.crates-io]
replace-with = 'aliyun'
[source.mirror]
registry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"
[source.aliyun]
registry = "sparse+https://mirrors.aliyun.com/crates.io-index/"
#[registries.mirror]
#index = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"
EOF
# fix permissions
chown -R codespace:codespace /workspace
chown -R codespace:codespace /home/codespace/
chmod 700 /home/codespace/.ssh
chmod 600 /home/codespace/.ssh/authorized_keys
# configuration
sudo -u codespace git config --global user.email "me@yqxpro.com"
sudo -u codespace git config --global user.name "QXYang686"
sudo -u codespace npm config set registry https://registry.npmmirror.com
sudo -u codespace ln -snf /workspace/dev-server /home/codespace/Projects