亚欧色一区w666天堂,色情一区二区三区免费看,少妇特黄A片一区二区三区,亚洲人成网站999久久久综合,国产av熟女一区二区三区

  • 發布文章
  • 消息中心
點贊
收藏
評論
分享
原創

[鏡像]雙架構鏡像的3種構建方法

2023-12-12 07:09:11
83
0

1. 背景

雙架構鏡像的好處是能根據當前的系統架構(x86或者arm64), 進行自動對應版本鏡像的拉取,避免了客戶端側去做這個鏡像tag的精確選擇。

 

2.構建方法

 

2.1 從源碼構建

例如一下以go項目為例子

Dockerfile: 

# Build
FROM golang:1.20 as builder
ENV GOPROXY "xxx://goproxy.cn,direct"
ENV GOPROVATE "gitlab.ctyuncdn.cn,git.fogcdn.top"
ADD . /workspace/project
WORKDIR /workspace/project

RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -o helloworld  main.go

FROM alpine:3.14

WORKDIR /usr/bin
COPY --from=builder /workspace/project/helloworld .
RUN chmod +x /usr/bin/helloworld
WORKDIR /home/helloworld
RUN mkdir -p /home/helloworld/log
ENTRYPOINT["/usr/bin/helloworld"]
 
編譯腳本:
#!/bin/bash

group=nest
registry=xxx
image=helloworld
DRONE_BRANCH=23.4.12
DRONE_BUILD_NUMBER=1

build(){
docker buildx create --use --name ${group} --node ${group}0
docker buildx build --platform=linux/arm64,linux/amd64 \
-f Dockerfile \
--push \
-t ${registry}/${image}:latest \
.
}

main(){
build $@
}

main $@
 
如上通過腳本就能完成雙架構的鏡像的構建和推送。 主要使用了docker buildx
 
 
2.2 手工打manifest
即基于現有的兩個架構的鏡像,手工打成一個manifest
 
 

docker manifest create --amend --insecure  xx/cruise-control:3.0.4 xx/cruise-control:3.0.4-amd xx/cruise-control:3.0.3-arm


# 給鏡像manifest文件添加arch信息
docker manifest annotate xx/cruise-control:3.0.4 xx/cruise-control:3.0.4-amd --arch amd64
docker manifest annotate xx/cruise-control:3.0.4 xx/cruise-control:3.0.3-arm --arch arm64

# 向swr鏡像倉庫推送鏡像manifest
docker manifest push -p --insecure xx/cruise-control:3.0.4
0條評論
0 / 1000
鄭****輝
7文章數
1粉絲數
鄭****輝
7 文章 | 1 粉絲
原創

[鏡像]雙架構鏡像的3種構建方法

2023-12-12 07:09:11
83
0

1. 背景

雙架構鏡像的好處是能根據當前的系統架構(x86或者arm64), 進行自動對應版本鏡像的拉取,避免了客戶端側去做這個鏡像tag的精確選擇。

 

2.構建方法

 

2.1 從源碼構建

例如一下以go項目為例子

Dockerfile: 

# Build
FROM golang:1.20 as builder
ENV GOPROXY "xxx://goproxy.cn,direct"
ENV GOPROVATE "gitlab.ctyuncdn.cn,git.fogcdn.top"
ADD . /workspace/project
WORKDIR /workspace/project

RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -o helloworld  main.go

FROM alpine:3.14

WORKDIR /usr/bin
COPY --from=builder /workspace/project/helloworld .
RUN chmod +x /usr/bin/helloworld
WORKDIR /home/helloworld
RUN mkdir -p /home/helloworld/log
ENTRYPOINT["/usr/bin/helloworld"]
 
編譯腳本:
#!/bin/bash

group=nest
registry=xxx
image=helloworld
DRONE_BRANCH=23.4.12
DRONE_BUILD_NUMBER=1

build(){
docker buildx create --use --name ${group} --node ${group}0
docker buildx build --platform=linux/arm64,linux/amd64 \
-f Dockerfile \
--push \
-t ${registry}/${image}:latest \
.
}

main(){
build $@
}

main $@
 
如上通過腳本就能完成雙架構的鏡像的構建和推送。 主要使用了docker buildx
 
 
2.2 手工打manifest
即基于現有的兩個架構的鏡像,手工打成一個manifest
 
 

docker manifest create --amend --insecure  xx/cruise-control:3.0.4 xx/cruise-control:3.0.4-amd xx/cruise-control:3.0.3-arm


# 給鏡像manifest文件添加arch信息
docker manifest annotate xx/cruise-control:3.0.4 xx/cruise-control:3.0.4-amd --arch amd64
docker manifest annotate xx/cruise-control:3.0.4 xx/cruise-control:3.0.3-arm --arch arm64

# 向swr鏡像倉庫推送鏡像manifest
docker manifest push -p --insecure xx/cruise-control:3.0.4
文章來自個人專欄
文章 | 訂閱
0條評論
0 / 1000
請輸入你的評論
0
0