FROM docker.internal.justin.tv/devtools/bionic/go1.11.4:latest

# Pull in the codebase to the docker container
WORKDIR /build/go/src/code.justin.tv/revenue/subscriptions
ADD . /build/go/src/code.justin.tv/revenue/subscriptions

# Run the local setup to avoid having to pull from remote tools repos. We already have the source files
RUN make setup-local

# Add everything in the current directory after setup is finished so that the git working directory is clean
RUN git add .

# Run `make twirp` to generate protobuff twirp interfaces
RUN make twirp

# Diff the git working directory for changed twirp or protobuff files. 
RUN git diff --exit-code --name-only *.twirp.go *.pb.go || (printf "\nRunning Make twirp changed generated code, please run Make twirp on your local branch and repush\n\n" & exit 1)