Protocol Buffersなdockerイメージ


自分用メモ。

Gitリポジトリ

環境

  • Docker version 19.03.8
  • docker-compose version 1.25.4

コード

ubuntuにprotbuf3.11.4を導入。(+GoogleAPIs)

Dockerfile
FROM ubuntu:18.04
ARG PB_VER=3.11.4
ENV GOOGLEAPIS_DIR=/googleapis
RUN cd /tmp && \
    apt-get update && \
    apt-get install -y curl unzip git && \
    git clone https://github.com/googleapis/googleapis.git && \
    mv googleapis / && \
    curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${PB_VER}/protoc-${PB_VER}-linux-x86_64.zip && \
    unzip protoc-${PB_VER}-linux-x86_64.zip && \
    mv bin/ /usr/local/ && \
    mv include/ /usr/local/ && \
    rm -f *
CMD [ "protoc", "--version" ]

docker-composeで確認(手抜き)。

docker-compose.yml
version: "3.7"
services: 
  protobuf:
    build: 
      context: ./
      # args: 
      #   PB_VER: 3.11.4
    image: protobuf-cli:3.11.4
    # command: [ protoc, --version ]
$ docker-compose run --rm protobuf
libprotoc 3.11.4

もしかしてalpineでもいける?
alpine版できました。