Skip to content

Instantly share code, notes, and snippets.

@PellePedro
Created April 9, 2021 20:48
Show Gist options
  • Save PellePedro/b752bcf9200ac444c8aef0af1cfd66ff to your computer and use it in GitHub Desktop.
Save PellePedro/b752bcf9200ac444c8aef0af1cfd66ff to your computer and use it in GitHub Desktop.
Building in Docker Container
FROM golang as build
# Build Arguments
ARG build
ARG version
# Install Dependencies
RUN apt-get update
RUN apt-get install -y git make curl unzip
WORKDIR /src
COPY . /src
ARG PB_VERSION=3.15.8
# Download & Install protoc
RUN curl -L https://github.com/protocolbuffers/protobuf/releases/download/v$PB_VERSION/protoc-$PB_VERSION-linux-x86_64.zip -o protoc.zip \
&& unzip protoc.zip -d protoc \
&& rm protoc.zip \
&& cp ./protoc/bin/protoc /usr/local/bin/protoc \
&& rm -rf ./protoc
RUN go get github.com/golang/protobuf/protoc-gen-go
#RUN make generate
RUN protoc -I protos --go_out=plugins=grpc,paths=source_relative:./protos protos/halo.proto
# Copy over to build output to scratch container
FROM scratch as artifact
COPY --from=build /src/protos/halo.pb.go /
# Run build as
# DOCKER_BUILDKIT=1 docker build --target=artifact --output type=local,dest=$(pwd)/protos/ -f Dockerfile.nvim .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment