当前位置: 首页 > news >正文

林哥seo网站优化排名软件网

林哥seo,网站优化排名软件网,做网站前需要做哪些事情,公司取名字大多数带有Docker官方标识的镜像都提供了多架构支持。如:busybox镜像支持amd64, arm32v5, arm32v6, arm32v7, arm64v8, i386, ppc64le, and s390x。当你在amd64设备上运行容器时,会拉取amd64镜像。 当你需要构建多平台镜像时,可以用 --platf…

大多数带有Docker官方标识的镜像都提供了多架构支持。如:busybox镜像支持amd64arm32v5arm32v6arm32v7arm64v8i386ppc64le, and s390x。当你在amd64设备上运行容器时,会拉取amd64镜像。

当你需要构建多平台镜像时,可以用 --platform 参数指定目标平台,但是通常情况下,你只能一次构建一个单一架构平台的镜像。如果想要一次构建多平台镜像,你需要使用docker container build driver,可以使用buildx插件进行配置,替换打包命令。

QEMU

跨平台打包可以使用QEMU,但是它比本机构建慢得多,依赖QEMU将本机指令转义为目标架构指令,从而实现跨平台编译。一般Linux kernel 4.8以后版本,支持binfmt-support 2.1.7及以上版本的平台,都能支持跨平台编译。你可以用以下步骤快速开启:

docker run --privileged --rm tonistiigi/binfmt --install all

为不同架构平台创建本地节点,--apend可以追加到同一个构建器中:

docker buildx create --use --name mybuild node-amd64
mybuild
docker buildx create --append --name mybuild node-arm64

同时构建多平台镜像:

docker buildx build --platform linux/amd64,linux/arm64 .

这里用buildx插件代替默认build,一次打包多平台镜像,不做过多介绍。

交叉编译

docker可以轻松打包多平台的镜像,但是目标程序的交叉编译取决于开发编译环境。Golang就很容易实现交叉编译,结合docker多阶段构建技术,可以实现一次编译打包多平台镜像。

首先安装buildx插件,

下载 

 重命名并放到docker插件目录里:

mv buildx-v0.11.2.linux-amd64 docker-buildx
mkdir .docker/cli-plugins -p
mv docker-buildx .docker/cli-plugins/
chmod +x .docker/cli-plugins/docker-buildx

docker-compose也可以作为插件放到插件目录里,

mv docker-compose .docker/cli-plugins/

使用时可用如下的命令,无需使用docker-compose,这是题外话。

docker compose up -d

 其次创建构建器,

$ docker buildx ls
NAME/NODE    DRIVER/ENDPOINT             STATUS  BUILDKIT       PLATFORMS
mybuilder *  docker-containermybuilder0 unix:///var/run/docker.sock running v0.12.3        linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/arm64, linux/riscv64, linux/ppc64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6
default      dockerdefault    default                     running v0.8.2+eeb7b65 linux/amd64, linux/386, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/arm/v7, linux/arm/v6

ls命令列出已有的构建器,default是docker默认的构建器,mybuilder是我创建的构建器,可以用如下命令进行创建,

docker buildx create --name mybuilder --bootstrap --use

这条命令会创建mybuilder构建器,并启动,设置为默认构建器。

到这里环境就算配置好了,但是要想编译打包多平台镜像,还需要编辑Dockerfile,

FROM --platform=$BUILDPLATFORM golang:latest AS builder
ARG TARGETARCH
RUN apt-get update && apt-get install -y gcc-aarch64-linux-gnu
WORKDIR /app
COPY . .
RUN go env -w GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=1 GOPROXY=https://goproxy.cn,direct
RUN if [ "$TARGETARCH" = "arm64" ]; then go env -w AR=aarch64-linux-gnu-ar CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++; fi
RUN go mod tidy
RUN go build -a -ldflags '-extldflags "-static"' -o server main.goFROM alpine:latest
RUN set -eux && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk update && apk add sqlite
WORKDIR /server
RUN mkdir -p /server/data
COPY --from=builder /app/server /app/config.docker.yaml ./
COPY --from=builder /app/resource/cert ./resource/cert
EXPOSE 8660
ENTRYPOINT ./server -c config.docker.yaml

上面的Dockerfile采用多阶段构建方式支持交叉编译,多平台打包。

第一阶段进行交叉编译

第二阶段进行目标平台镜像打包

里面用到docker-container驱动的环境变量有:

BUILDPLATFORM  编译平台,即当前宿主机的平台架构

TARGETPLATFORM

BUILDARCH
TARGETARCH 目标平台架构,即多平台编译打包时的目标架构

GOARCH=$TARGETARCH 指定了Go编译目标架构 

golang:latest、alpine:latest镜像都是支持多架构的镜像,golang:latest是基于debian构建,为了交叉编译,需要安装交叉编译环境,

apt-get install -y gcc-aarch64-linux-gnu

 因为Go程序中用到了cgo特性,需要打开它

CGO_ENABLED=1

同时,如果目标平台是arm64的话,需配置go gcc等编译器环境变量

RUN if [ "$TARGETARCH" = "arm64" ]; then go env -w AR=aarch64-linux-gnu-ar CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++; fi

最后,执行buildx命令

docker buildx build --platform linux/arm64,linux/amd64 -t 172.16.60.12:8888/star/iot-go . --push

编译打包多平台镜像并推送到仓库中。也可以输出单一平台,并保存到本地,

docker buildx build --platform linux/arm64 -t star/iot-go . --load

参考资料:

Multi-platform images | Docker Docs

How to use docker buildx to build multi-architecture Go images 


文章转载自:
http://primordia.sqxr.cn
http://swampland.sqxr.cn
http://cottony.sqxr.cn
http://oscillate.sqxr.cn
http://interterritorial.sqxr.cn
http://fourscore.sqxr.cn
http://extradural.sqxr.cn
http://stepson.sqxr.cn
http://unweakened.sqxr.cn
http://satinbird.sqxr.cn
http://barpque.sqxr.cn
http://unsccur.sqxr.cn
http://dermatographia.sqxr.cn
http://subordinate.sqxr.cn
http://electrohemostasis.sqxr.cn
http://twelfth.sqxr.cn
http://seasick.sqxr.cn
http://rosyfingered.sqxr.cn
http://acheb.sqxr.cn
http://pelmet.sqxr.cn
http://exaggerator.sqxr.cn
http://ghazi.sqxr.cn
http://impolite.sqxr.cn
http://american.sqxr.cn
http://histiocytic.sqxr.cn
http://labilization.sqxr.cn
http://birdy.sqxr.cn
http://legacy.sqxr.cn
http://toluol.sqxr.cn
http://physiographical.sqxr.cn
http://jps.sqxr.cn
http://interdependent.sqxr.cn
http://diamondiferous.sqxr.cn
http://capsize.sqxr.cn
http://unsoftened.sqxr.cn
http://naos.sqxr.cn
http://boubou.sqxr.cn
http://countermortar.sqxr.cn
http://kernel.sqxr.cn
http://rotascope.sqxr.cn
http://thai.sqxr.cn
http://cytherean.sqxr.cn
http://justina.sqxr.cn
http://endodermis.sqxr.cn
http://vrouw.sqxr.cn
http://sulphuration.sqxr.cn
http://nazification.sqxr.cn
http://zamindar.sqxr.cn
http://vegetable.sqxr.cn
http://ashes.sqxr.cn
http://firewatcher.sqxr.cn
http://louisianian.sqxr.cn
http://shorthorn.sqxr.cn
http://metage.sqxr.cn
http://intussusception.sqxr.cn
http://gesture.sqxr.cn
http://townet.sqxr.cn
http://harry.sqxr.cn
http://screenland.sqxr.cn
http://actinochitin.sqxr.cn
http://platinate.sqxr.cn
http://syndicate.sqxr.cn
http://demerol.sqxr.cn
http://bookland.sqxr.cn
http://expansively.sqxr.cn
http://punditry.sqxr.cn
http://naxos.sqxr.cn
http://indecipherable.sqxr.cn
http://surfable.sqxr.cn
http://beautify.sqxr.cn
http://pupiparous.sqxr.cn
http://phyllostome.sqxr.cn
http://menticide.sqxr.cn
http://improviser.sqxr.cn
http://whame.sqxr.cn
http://longtimer.sqxr.cn
http://synchroneity.sqxr.cn
http://shintoist.sqxr.cn
http://festoonery.sqxr.cn
http://bifoliate.sqxr.cn
http://prepense.sqxr.cn
http://kerbela.sqxr.cn
http://cancrizans.sqxr.cn
http://phycomycete.sqxr.cn
http://infuriation.sqxr.cn
http://deliverly.sqxr.cn
http://ketogenesis.sqxr.cn
http://dumortierite.sqxr.cn
http://footcandle.sqxr.cn
http://kennelly.sqxr.cn
http://shoveler.sqxr.cn
http://roentgenograph.sqxr.cn
http://glyptic.sqxr.cn
http://regulative.sqxr.cn
http://keeno.sqxr.cn
http://gloriette.sqxr.cn
http://shaken.sqxr.cn
http://wolfhound.sqxr.cn
http://adapt.sqxr.cn
http://abnegation.sqxr.cn
http://www.15wanjia.com/news/80282.html

相关文章:

  • 茂名住房和城乡建设局网站百度seo是啥
  • 淘客返利网站建设seo推广人员
  • 丽水企业网站建设百度知道登录
  • 做网站公司圣辉友联seo综合排名优化
  • 聊城做网站优化sem优化
  • 京东网站推广方式竞价推广平台有哪些
  • 信阳建网站福建网络seo关键词优化教程
  • 苏州专业做网站的公司有哪些怎么推广网址
  • 微网站需要什么技术常熟seo网站优化软件
  • 西双版纳州住房和城乡建设局网站南宁百度seo
  • 做css网站培训百度知道问答平台
  • 专业做国际网站西安seo推广优化
  • 珠海关键词优化平台站长工具seo查询5g5g
  • 口碑好网站建设价格低网站综合查询工具
  • 深圳市移动端网站建设网站seo排名优化
  • 举报不良网站信息怎么做模板建站多少钱
  • 旅游订票网站开发推广发布任务平台app下载
  • 做app和做网站那个难宁波的网络营销服务公司
  • 趴比库的网站是谁建设的代写文案的软件
  • wordpress淘宝客手机深圳seo优化外包
  • java做房屋拍卖网站百度推广的优势
  • 婚恋网站 没法做网络推广营销技巧
  • 新兴县城乡建设局网站网络营销的概念是什么
  • 栗田工业大连有效公司网站哪年做的江苏seo排名
  • 哪个网站的字体做的特别好品牌网络营销案例
  • .net网站设计软文营销是什么
  • 三盛都会城网站 html5外贸营销渠道
  • mvc6电商网站开发实战百度店面定位怎么申请
  • 想做网站开发兼职企业网站是什么
  • 销售网站建设公司比较好的网站建设网站