Skip to content

Commit

Permalink
Push changes to containerise Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
aishwarya9404 committed Oct 10, 2023
1 parent 4f6295a commit e349541
Show file tree
Hide file tree
Showing 8 changed files with 865 additions and 5,053 deletions.
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Do not use directly, use `make docker-build-proto` instead
#

FROM golang:1.19
ENV GOPATH=/go
WORKDIR ${GOPATH}/src/github.com/lib/px-api/

RUN apt-get update && \
apt-get install -y clang-format unzip golang-grpc-gateway gogoprotobuf && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip
RUN unzip protoc-3.14.0-linux-x86_64.zip -d /usr/local

RUN curl -OL https://github.com/grpc-ecosystem/grpc-gateway/archive/refs/tags/v2.2.0.tar.gz
RUN mkdir -p ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/ && tar -xvf v2.2.0.tar.gz -C ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/ --strip-components=1 && rm -f v2.2.0.tar.gz

RUN git clone https://github.com/gogo/protobuf.git ${GOPATH}/src/github.com/gogo/protobuf

COPY go.mod go.sum ${WORKDIR}/

RUN go get -u \
google.golang.org/protobuf \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
36 changes: 7 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,13 @@ GO111MODULE := on

.DEFAULT_GOAL: all

all: proto pretest

centos:
# Installation is specific for centos based distribution
yum install -y centos-release-scl && yum install -y llvm-toolset-7 && yum makecache && yum install -y unzip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/$(PROTOC_ZIP)
unzip -o $(PROTOC_ZIP) -d /usr bin/protoc
rm -f $(PROTOC_ZIP)
scl enable llvm-toolset-7 "clang-format -i $(PROTOC_FILES)"
all: docker-build-proto

docker-build-proto:
docker build . -t px-api:1
docker run --rm -v ${PWD}:/go/src/github.com/lib/px-api px-api:1 /bin/bash -c "make proto pretest"

proto:
apt install clang-format
rm -rf ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/
mkdir -p ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/
curl -OL https://github.com/grpc-ecosystem/grpc-gateway/archive/refs/tags/v2.2.0.tar.gz
tar -xvf v2.2.0.tar.gz -C ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/ --strip-components=1
rm -f v2.2.0.tar.gz

rm -rf ${GOPATH}/src/github.com/gogo/protobuf/
mkdir -p ${GOPATH}/src/github.com/gogo/protobuf/
git clone [email protected]:gogo/protobuf.git ${GOPATH}/src/github.com/gogo/protobuf

go get -u \
github.com/gogo/protobuf/protoc-gen-gogo \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \
github.com/gogo/protobuf/protoc-gen-gogofaster \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
$(PROTOC) -I/usr/local/include -I. \
-I${GOPATH}/src \
-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-openapiv2 \
Expand Down Expand Up @@ -76,17 +55,16 @@ Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api,\
Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types:.\
--swagger_out=logtostderr=true:. \
$(PROTOC_FILES)

pretest: vet staticcheck errcheck
pretest: vet staticcheck errcheck

vet:
go vet $(PKGS)

staticcheck:
GOFLAGS="" go install honnef.co/go/tools/cmd/staticcheck@v0.2.2
GOFLAGS="" go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck $(PKGS)

errcheck:
go get -u github.com/kisielk/errcheck
go install github.com/kisielk/errcheck@latest
errcheck -ignoregenerated -verbose -blank $(PKGS)

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The generated client code is present under

## Building

After updating the proto definitions, run `make` to regenerate the client libraries and swagger definitions.
After updating the proto definitions, run `make docker-build-proto` to regenerate the client libraries and swagger definitions.

## Usage

Expand Down
10 changes: 8 additions & 2 deletions pkg/apis/v1/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e349541

Please sign in to comment.