首页 > 其他分享 >Dockerfile - Install protoc

Dockerfile - Install protoc

时间:2024-04-17 21:23:58浏览次数:26  
标签:protoc && proto -- PROTOC Install go Dockerfile

 

FROM --platform=$BUILDPLATFORM alpine as protoc
ARG BUILDPLATFORM=linux/amd64 TARGETOS=linux TARGETARCH=amd64

# download the protoc binary from github
# We unzip the file into /usr/local. Notice that we are extracting both the protoc
# binary (/bin/protoc) and the /include folder because the first one is the compiler that we are
# going to use and the second one is all the files needed to include Well-Known Types.
RUN export PROTOC_VERSION=26.1 \
    && export PROTOC_OS=$(echo $TARGETOS | sed s/darwin/linux/) \
    && export PROTOC_ARCH=$(uname -m | sed s/aarch64/aarch_64/) \
    && export PROTOC_ZIP=protoc-$PROTOC_VERSION-$PROTOC_OS-$PROTOC_ARCH.zip \
    && echo "downloading: " https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP \
    && wget https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP \
    && unzip -o $PROTOC_ZIP -d /usr/local bin/protoc 'include/*' \
    && rm -f $PROTOC_ZIP


FROM --platform=$BUILDPLATFORM golang:1.22-alpine as build
ARG BUILDPLATFORM=linux/amd64 TARGETOS=linux TARGETARCH=amd64

# copy the protoc binary and the protobuf includes
COPY --from=protoc /usr/local/bin/protoc /usr/local/bin/protoc
COPY --from=protoc /usr/local/include/google /usr/local/include/google

# dowload protoc plugins
RUN go env -w GOPROXY=https://goproxy.io,direct
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
RUN go install github.com/envoyproxy/protoc-gen-validate@latest

# copy proto files into go/src/proto
WORKDIR /go/src/proto
COPY ./proto .

# generate code out of proto files
WORKDIR /go/src
RUN mkdir pb
RUN protoc --proto_path=proto \
           --go_out=pb \
           --go_opt=paths=source_relative \
           --go-grpc_out=pb \
           --go-grpc_opt=paths=source_relative \
           --validate_out="lang=go,paths=source_relative:pb" \
           proto/*.proto

 

标签:protoc,&&,proto,--,PROTOC,Install,go,Dockerfile
From: https://www.cnblogs.com/zhangzhihui/p/18141788

相关文章

  • 【安装记录】pip install dlib报错
    最近在复现人工智能方面的论文时,需要安装dlib包但是pipinstalldlib一直报错:又有中文乱码,又提示下面的:note:Thiserrororiginatesfromasubprocess,andislikelynotaproblemwithpip.ERROR:FailedbuildingwheelfordlibRunningsetup.pycleanfordlibFail......
  • electron npm install 报错解决方案
    问题解决方案ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/......
  • Docker使用Dockerfile部署Fastapi应用
    1#使用官方的Python运行时作为基础镜像2FROMpython:3.9-slim34#设置工作目录5WORKDIR/app67#复制应用程序的依赖文件到工作目录8COPYrequirements.txt.910#安装应用程序的依赖11RUNpipinstall--no-cache-dir-rrequirements.txt12......
  • DOCKER配置之DOCKERFILE
    要跑深度学习,就要有环境,要有环境就要有虚拟环境管理一般python管理都会用ANACONDA或者MINICONDA,这个时候使用conda就直接结了,不需要再关心其他事情。然而部分数据集Ubuntu18.04的环境实在是过于逆天(不是针对某个数据集或代码,只能说大部分数据集和代码都在18.04以及python3.8的远......
  • 通过 aqtinstall 安装 Qt5 的库
    QtMaintenanceTool(QtOnlineInstaller)可能没有Qt5的安装选项了,但是从Qt官网下载的qt-opensource-windows-x86-5.14.2.exe安装器在安装的时候会安装旧的QtCreator。如果你不想要旧的QtCreator并且需要的版本不是Qt5.14.2,安装起来可能不是很方便。有一个命令行工具可......
  • conda install sometools报错:CondaHTTPError: HTTP 000 CONNECTION FAILED for url <h
    把该错误投入chatgpt中会反映网络问题,重试几次但我重试了好几天也没安上,重新搜索该报错发现:ThatHTTPerrorhappenedwhenIupdatedthecondawith condaupdateconda.ItriedalloptionsdiscussedherebutitonlywassolvedwhenIdowngradedthecondaversion(I......
  • IDEA突然提示git is not installed Cannot identify version of git executable:no re
    闲话:早上来打开IDEA编辑器,突然发现Git消失了,下意识点了一下安装git,等了一会发现安装失败!好嘛,大早上的事来了。随后调整了一个上午,最后实在忍不住起来上厕所,烦躁的不行把笔记本关机重启,回来发现居然自己恢复了。现在我把我查询的过程都记录下来,希望能有帮助到......
  • fs.1.10 ON CENTOS7 dockerfile模式
     概述freeswitch是一款简单好用的VOIP开源软交换平台。centos7docker上编译安装fs.1.10的流程记录,本文使用dockerfile模式。环境dockerengine:Version24.0.6centosdocker:7freeswitch:v1.10.7dockerfile创建空目录,创建dockerfile文件。github访问经常失败,先下载好源......
  • Dockerfile 安装centos案例
    1.编写dockerfile文件去安装cetos的操作步骤:   2.执行Dockerfile文件:dockerbuild-tcentosjava8:1.5.ps:其中,-t选项用于指定镜像的名称,centosjava8:1.5是你为镜像命名的名称,可以替换成其他任意名称。.表示当前目录,指示Docker在当前目录下寻找Dockerfil......
  • 嵌入式设备(T507)运行qml程序提示module is not installed
    T507设备中运行qml编写的程序,提示module未安装,如下图。这是因为程序运行时未找到QML库导致的,需要在qtenv.sh文件或者系统环境变量中导出QML库在嵌入式设备文件系统中的位置,修改后如下:1exportQML2_IMPORT_PATH=$QT_ROOT/qmlqtenv.sh文件完整内容如下:1exportQTDIR=/u......