构建脚本准备
This commit is contained in:
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 "$@"
|
||||
12
build/builder-setup.sh
Normal file
12
build/builder-setup.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
set -eux
|
||||
|
||||
export TARGET_USER=ecs-user
|
||||
export REGISTRY_IP=172.22.178.82
|
||||
|
||||
sudo apt update
|
||||
sudo apt install -y npm git
|
||||
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
|
||||
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
|
||||
Reference in New Issue
Block a user