Compare commits
6 Commits
4285293f82
...
f7cb2a948c
| Author | SHA1 | Date | |
|---|---|---|---|
| f7cb2a948c | |||
| e123799495 | |||
| 200a08e816 | |||
| c06c1f3404 | |||
| 3e4c54e29a | |||
| 41ad420c72 |
1
authorized_keys
Normal file
1
authorized_keys
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEXPddCUCbsAShg6+21q/MIvFM27xlqVr+Yg3MoHqUZp
|
||||||
37
build/build-image.sh
Normal file
37
build/build-image.sh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
export BUILDX_BUILDER=hk-builder
|
||||||
|
|
||||||
|
export REGISTRY="registry.yqxpro.com"
|
||||||
|
|
||||||
|
export S3_ENDPOINT_URL=https://oss-cn-hongkong-internal.aliyuncs.com
|
||||||
|
export S3_REGION=cn-hongkong
|
||||||
|
export S3_BUCKET=hk-builder-cache-yqxpro
|
||||||
|
export S3_ACCESSKEY=LTAI5t8AtjWfsqQWYnyBeCjH
|
||||||
|
export S3_SECRETKEY=UPKF20AmcW2zB5BwAMIQeQgZeTkMEs
|
||||||
|
export S3_CONFIG=endpoint_url=${S3_ENDPOINT_URL},region=${S3_REGION},bucket=${S3_BUCKET},access_key_id=${S3_ACCESSKEY},secret_access_key=${S3_SECRETKEY}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
local target="$1"
|
||||||
|
|
||||||
|
echo "Build $target started"
|
||||||
|
|
||||||
|
pushd $target
|
||||||
|
npx devcontainer build \
|
||||||
|
--platform linux/amd64,linux/arm64 \
|
||||||
|
--image-name ${REGISTRY}/devcontainers/$target --push \
|
||||||
|
--cache-to type=s3,${S3_CONFIG},prefix=$target/,mode=max \
|
||||||
|
--cache-from type=s3,${S3_CONFIG},prefix=$target/
|
||||||
|
popd
|
||||||
|
|
||||||
|
echo "Build $target completed"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
for target in "$@"; do
|
||||||
|
build "$target"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
10
build/builder-setup.sh
Normal file
10
build/builder-setup.sh
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
export TARGET_USER=ecs-user
|
||||||
|
export REGISTRY_IP=172.22.178.82
|
||||||
|
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/docker/docker-install/master/install.sh | sh
|
||||||
|
sudo usermod -aG docker $TARGET_USER
|
||||||
|
|
||||||
|
echo "$REGISTRY_IP registry.yqxpro.com" | sudo tee -a /etc/hosts
|
||||||
19
build/host-setup.sh
Normal file
19
build/host-setup.sh
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
# SSH 配置中先准备好 hk-builder-linux-arm64 和 hk-builder-linux-amd64
|
||||||
|
docker buildx create \
|
||||||
|
--name hk-builder \
|
||||||
|
--driver docker-container \
|
||||||
|
--driver-opt network=host \
|
||||||
|
--platform linux/amd64 \
|
||||||
|
--node hk-builder-linux-amd64 \
|
||||||
|
ssh://hk-builder-linux-amd64
|
||||||
|
docker buildx create \
|
||||||
|
--name hk-builder \
|
||||||
|
--driver docker-container \
|
||||||
|
--driver-opt network=host \
|
||||||
|
--platform linux/arm64 \
|
||||||
|
--append \
|
||||||
|
--node hk-builder-linux-arm64 \
|
||||||
|
ssh://hk-builder-linux-arm64
|
||||||
36
build/publish-image.sh
Normal file
36
build/publish-image.sh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
export REGISTRY=registry.yqxpro.com
|
||||||
|
export REGISTRY_PUBLISH=crpi-kbfsbvlqwt19zxum-vpc.cn-hongkong.personal.cr.aliyuncs.com/registry-yqxpro
|
||||||
|
export TAG=$(git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y skopeo
|
||||||
|
|
||||||
|
docker login $REGISTRY_PUBLISH
|
||||||
|
|
||||||
|
skopeo copy --all \
|
||||||
|
docker://${REGISTRY}/devcontainers/common-base:latest \
|
||||||
|
docker://${REGISTRY_PUBLISH}/devcontainers-common-base:latest
|
||||||
|
skopeo copy --all \
|
||||||
|
docker://${REGISTRY}/devcontainers/common-base:latest \
|
||||||
|
docker://${REGISTRY_PUBLISH}/devcontainers-common-base:${TAG}
|
||||||
|
|
||||||
|
skopeo copy --all \
|
||||||
|
docker://${REGISTRY}/devcontainers/develop-base:latest \
|
||||||
|
docker://${REGISTRY_PUBLISH}/devcontainers-develop-base:latest
|
||||||
|
skopeo copy --all \
|
||||||
|
docker://${REGISTRY}/devcontainers/develop-base:latest \
|
||||||
|
docker://${REGISTRY_PUBLISH}/devcontainers-develop-base:${TAG}
|
||||||
|
|
||||||
|
skopeo copy --all \
|
||||||
|
docker://${REGISTRY}/devcontainers/universal-base:latest \
|
||||||
|
docker://${REGISTRY_PUBLISH}/devcontainers-universal-base:latest
|
||||||
|
skopeo copy --all \
|
||||||
|
docker://${REGISTRY}/devcontainers/universal-base:latest \
|
||||||
|
docker://${REGISTRY_PUBLISH}/devcontainers-universal-base:${TAG}
|
||||||
|
|
||||||
|
skopeo copy --all \
|
||||||
|
docker://${REGISTRY}/devcontainers/universal-base:latest \
|
||||||
|
oci-archive:devcontainers-universal-base.tar
|
||||||
13
build/registry-setup.sh
Normal file
13
build/registry-setup.sh
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
tar xvzf certs.tgz
|
||||||
|
docker run -d \
|
||||||
|
--restart=always \
|
||||||
|
--name registry \
|
||||||
|
-v "$(pwd)"/certs:/certs \
|
||||||
|
-e REGISTRY_HTTP_ADDR=0.0.0.0:443 \
|
||||||
|
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/registry.yqxpro.com.crt \
|
||||||
|
-e REGISTRY_HTTP_TLS_KEY=/certs/registry.yqxpro.com.key \
|
||||||
|
-p 443:443 \
|
||||||
|
registry:3
|
||||||
13
combined-init.sh
Normal file
13
combined-init.sh
Normal 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 "$@"
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
"username": "codespace",
|
"username": "codespace",
|
||||||
"userUid": "1000",
|
"userUid": "1000",
|
||||||
"userGid": "1000",
|
"userGid": "1000",
|
||||||
"configureZshAsDefaultShell": true,
|
|
||||||
},
|
},
|
||||||
"ghcr.io/devcontainers/features/sshd:1": {
|
"ghcr.io/devcontainers/features/sshd:1": {
|
||||||
"gatewayPorts": "yes",
|
"gatewayPorts": "yes",
|
||||||
|
|||||||
33
docker-compose.yml
Normal file
33
docker-compose.yml
Normal 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
36
once-init.sh
Normal 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
|
||||||
23
publish.sh
23
publish.sh
@@ -1,23 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
export REGISTRY=registry.yqxpro.com
|
|
||||||
export REGISTRY_PUBLISH=crpi-kbfsbvlqwt19zxum-vpc.cn-hongkong.personal.cr.aliyuncs.com/registry-yqxpro
|
|
||||||
export TAG=$(git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
docker login $REGISTRY_PUBLISH
|
|
||||||
|
|
||||||
docker tag registry.yqxpro.com/devcontainers/common-base:latest $REGISTRY_PUBLISH/devcontainers-common-base:latest
|
|
||||||
docker tag registry.yqxpro.com/devcontainers/common-base:latest $REGISTRY_PUBLISH/devcontainers-common-base:$TAG
|
|
||||||
docker push $REGISTRY_PUBLISH/devcontainers-common-base:latest
|
|
||||||
docker push $REGISTRY_PUBLISH/devcontainers-common-base:$TAG
|
|
||||||
|
|
||||||
docker tag registry.yqxpro.com/devcontainers/develop-base:latest $REGISTRY_PUBLISH/devcontainers-develop-base:latest
|
|
||||||
docker tag registry.yqxpro.com/devcontainers/develop-base:latest $REGISTRY_PUBLISH/devcontainers-develop-base:$TAG
|
|
||||||
docker push $REGISTRY_PUBLISH/devcontainers-develop-base:latest
|
|
||||||
docker push $REGISTRY_PUBLISH/devcontainers-develop-base:$TAG
|
|
||||||
|
|
||||||
docker tag registry.yqxpro.com/devcontainers/universal-base:latest $REGISTRY_PUBLISH/devcontainers-universal-base:latest
|
|
||||||
docker tag registry.yqxpro.com/devcontainers/universal-base:latest $REGISTRY_PUBLISH/devcontainers-universal-base:$TAG
|
|
||||||
docker push $REGISTRY_PUBLISH/devcontainers-universal-base:latest
|
|
||||||
docker push $REGISTRY_PUBLISH/devcontainers-universal-base:$TAG
|
|
||||||
@@ -56,7 +56,7 @@ fi
|
|||||||
usermod -a -G nvs "${USERNAME}"
|
usermod -a -G nvs "${USERNAME}"
|
||||||
|
|
||||||
git config --global --add safe.directory ${NVS_HOME}
|
git config --global --add safe.directory ${NVS_HOME}
|
||||||
mkdir -p ${NVS_HOME}
|
mkdir -p ${NVS_HOME}
|
||||||
|
|
||||||
git clone -c advice.detachedHead=false --depth 1 https://github.com/jasongin/nvs ${NVS_HOME} 2>&1
|
git clone -c advice.detachedHead=false --depth 1 https://github.com/jasongin/nvs ${NVS_HOME} 2>&1
|
||||||
(cd ${NVS_HOME} && git remote get-url origin && echo $(git log -n 1 --pretty=format:%H -- .)) > ${NVS_HOME}/.git-remote-and-commit
|
(cd ${NVS_HOME} && git remote get-url origin && echo $(git log -n 1 --pretty=format:%H -- .)) > ${NVS_HOME}/.git-remote-and-commit
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ fi
|
|||||||
|
|
||||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||||
rm -f /etc/profile.d/00-restore-env.sh
|
rm -f /etc/profile.d/00-restore-env.sh
|
||||||
echo $SHELL
|
touch /etc/profile.d/00-restore-env.sh # 暂时把有问题的替换忽略
|
||||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
|
# echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
|
||||||
chmod +x /etc/profile.d/00-restore-env.sh
|
chmod +x /etc/profile.d/00-restore-env.sh
|
||||||
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|||||||
Reference in New Issue
Block a user