|
1 | | -FROM golang:alpine |
| 1 | +FROM golang:1.23-alpine |
2 | 2 |
|
3 | | -RUN mkdir /proto |
4 | | - |
5 | | -RUN mkdir /stubs |
6 | | - |
7 | | -RUN apk -U --no-cache add git protobuf bash |
8 | | - |
9 | | -RUN go install -v github.com/golang/protobuf/protoc-gen-go@latest |
10 | | - |
11 | | -RUN go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest |
12 | | - |
13 | | -RUN go install github.com/markbates/pkger/cmd/pkger@latest |
| 3 | +# install tools (bash, git, protobuf, protoc-gen-go, protoc-grn-go-grpc, pkger) |
| 4 | +RUN apk -U --no-cache add bash git protobuf &&\ |
| 5 | + go install -v github.com/golang/protobuf/protoc-gen-go@latest &&\ |
| 6 | + go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0 &&\ |
| 7 | + go install github.com/markbates/pkger/cmd/pkger@latest |
14 | 8 |
|
15 | 9 | # cloning well-known-types |
16 | | -RUN git clone --depth=1 https://github.com/google/protobuf.git /protobuf-repo |
17 | | - |
18 | | -RUN mkdir protobuf |
19 | | - |
20 | 10 | # only use needed files |
21 | | -RUN mv /protobuf-repo/src/ /protobuf/ |
22 | | - |
23 | | -RUN rm -rf /protobuf-repo |
24 | | - |
25 | | -RUN mkdir -p /go/src/github.com/tokopedia/gripmock |
| 11 | +RUN git clone --depth=1 https://github.com/google/protobuf.git /protobuf-repo &&\ |
| 12 | + mv /protobuf-repo/src/ /protobuf/ &&\ |
| 13 | + rm -rf /protobuf-repo |
26 | 14 |
|
27 | 15 | COPY . /go/src/github.com/tokopedia/gripmock |
28 | 16 |
|
29 | | -RUN ln -s /go/src/github.com/tokopedia/gripmock/fix_gopackage.sh /bin/ |
| 17 | +# create necessary dirs and export scripts |
| 18 | +RUN mkdir -p /proto /stubs /protogen &&\ |
| 19 | + chmod +x /go/src/github.com/tokopedia/gripmock/scripts/*.sh &&\ |
| 20 | + ln -s /go/src/github.com/tokopedia/gripmock/scripts/fix_gopackage.sh /bin/ &&\ |
| 21 | + ln -s /go/src/github.com/tokopedia/gripmock/scripts/start_server.sh /bin/ &&\ |
| 22 | + ln -s /go/src/github.com/tokopedia/gripmock/scripts/wait_for_gripmock.sh /bin/ |
30 | 23 |
|
31 | | -WORKDIR /go/src/github.com/tokopedia/gripmock/protoc-gen-gripmock |
| 24 | +# Copy server.go and go.mod to /go/src/grpc |
| 25 | +# to build go module |
| 26 | +RUN mkdir -p /go/src/grpc &&\ |
| 27 | + cp /go/src/github.com/tokopedia/gripmock/scripts/server/server.go /go/src/grpc/ &&\ |
| 28 | + cp /go/src/github.com/tokopedia/gripmock/scripts/server/go.mod /go/src/grpc/ |
32 | 29 |
|
33 | | -RUN pkger |
| 30 | +# install plugin protoc-gen-go-grpc |
| 31 | +WORKDIR /go/src/github.com/tokopedia/gripmock/protoc-gen-gripmock |
34 | 32 |
|
35 | 33 | # install generator plugin |
36 | | -RUN go install -v |
| 34 | +RUN rm -f pkged.go && pkger && go install -v |
37 | 35 |
|
38 | 36 | WORKDIR /go/src/github.com/tokopedia/gripmock |
39 | 37 |
|
40 | 38 | # install gripmock |
41 | 39 | RUN go install -v |
42 | 40 |
|
43 | | -# to cache necessary imports |
44 | | -RUN go build ./example/simple/client |
| 41 | +# cache the dependencies then clean up |
| 42 | +RUN ./scripts/setup_examples.sh && \ |
| 43 | + go build example/simple/client/*.go && \ |
| 44 | + find . -name "*.pb.go" -type f -delete |
45 | 45 |
|
46 | | -# remove all .pb.go generated files |
47 | | -# since generating go file is part of the test |
48 | | -RUN find . -name "*.pb.go" -delete -type f |
| 46 | +# run server for caching purposes |
| 47 | +RUN start_server.sh |
49 | 48 |
|
50 | 49 | EXPOSE 4770 4771 |
51 | 50 |
|
52 | 51 | ENTRYPOINT ["gripmock"] |
| 52 | +CMD ["--help"] |
0 commit comments