Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This Dockerfile produces an image that runs the protocol compiler
# to generate Go declarations for messages and Twirp RPC interfaces.
#
# For build reproducibility, it is explicit about the versions of its
# dependencies, which include:
# - the golang base docker image (linux, go, git),
# - protoc,
# - Go packages (protoc-gen-go and protoc-gen-twirp),
# - apt packages (unzip).

FROM golang:1.16.5

WORKDIR /work

RUN apt-get update && \
apt-get install -y unzip=6.0-23+deb10u2 && \
curl --location --silent -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protoc-3.13.0-linux-x86_64.zip && \
unzip protoc.zip -d /usr/local/ && \
rm -fr protoc.zip

RUN go get google.golang.org/protobuf/cmd/protoc-gen-go@v1.20.0 \
github.com/twitchtv/twirp/protoc-gen-twirp@v5.12.1+incompatible

ENTRYPOINT ["protoc"]
31 changes: 5 additions & 26 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ package main

import (
"bytes"
_ "embed"
"flag"
"fmt"
"log"
Expand All @@ -51,6 +52,10 @@ import (
"strings"
)

// dockerfile contains the docker specification for our versioned dependencies
//go:embed Dockerfile
var dockerfile string

func main() {
log.SetPrefix("proto-gen-go: ")
log.SetFlags(0)
Expand Down Expand Up @@ -90,29 +95,3 @@ func main() {
}
log.Println("done")
}

// This Dockerfile produces an image that runs the protocol compiler
// to generate Go declarations for messages and Twirp RPC interfaces.
//
// For build reproducibility, it is explicit about the versions of its
// dependencies, which include:
// - the golang base docker image (linux, go, git),
// - protoc,
// - Go packages (protoc-gen-go and protoc-gen-twirp),
// - apt packages (unzip).
const dockerfile = `
FROM golang:1.16.5

WORKDIR /work

RUN apt-get update && \
apt-get install -y unzip=6.0-23+deb10u2 && \
curl --location --silent -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protoc-3.13.0-linux-x86_64.zip && \
unzip protoc.zip -d /usr/local/ && \
rm -fr protoc.zip

RUN go get google.golang.org/protobuf/cmd/protoc-gen-go@v1.20.0 \
github.com/twitchtv/twirp/protoc-gen-twirp@v5.12.1+incompatible

ENTRYPOINT ["protoc"]
`