Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containerise Makefile using Dockerfile #218

Merged
merged 2 commits into from
Oct 11, 2023
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
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Do not use directly, use `make docker-build-proto` instead
#

FROM golang:1.20
ENV GOPATH=/go
RUN mkdir -p portworx/px-backup-api
WORKDIR portworx/px-backup-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
37 changes: 9 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,16 @@ GO111MODULE := on

.DEFAULT_GOAL: all

all: proto pretest
all: docker-build-proto

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)"
docker-build-proto:
docker build . -t px-backup-api-build
docker run --rm -v ${PWD}:/go/portworx/px-backup-api px-backup-api-build /bin/bash -c "make proto pretest"

start-build-container:
docker run --rm -it -v ${PWD}:/go/portworx/px-backup-api px-backup-api-build /bin/bash

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 +58,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)

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ 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.

Run `make start-build-container` to exec into the docker container and run any `make` commands

## 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
Loading