forked from jllopis/docker-go-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-alpine
87 lines (71 loc) · 2.38 KB
/
Dockerfile-alpine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# $ docker run -ti -v $PWD:/go/src/bitbucket.org/acbapis/legalitas -v /Users/jllopis/devel/go/own/src/bitbucket.org/acbapis/acbapis:/go/src/bitbucket.org/acbapis/acbapis buildert bitbucket.org/acbapis/legalitas bGludXgK
FROM golang:1.12.4-alpine3.9 AS builder
# gcc for cgo
RUN buildDeps='build-base libressl-dev util-linux-dev curl autoconf automake zlib clang g++ gcc wget'; \
apk update && \
apk add git \
unzip \
ca-certificates \
libtool \
$buildDeps
ENV GOLANG_VERSION 1.12.4
ENV PROTOC_VERSION 3.7.1
ENV GRPC_GO_VERSION 1.28.0
ENV GRPC_GATEWAY_VERSION 1.8.5
# Install protocol buffers compiler
RUN wget https://github.com/google/protobuf/archive/v${PROTOC_VERSION}.tar.gz && \
tar zxvf v${PROTOC_VERSION}.tar.gz && \
cd protobuf-${PROTOC_VERSION} && \
./autogen.sh && \
./configure && \
make && \
make install && \
ldconfig / && \
cd ${GOPATH} && \
rm v${PROTOC_VERSION}.tar.gz && \
rm -rf protobuf-${PROTOC_VERSION}
# Install grpc-go and grpc-gateway and companions
RUN go get -u google.golang.org/grpc ; \
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway ; \
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
# Install go grpc protobuf plugin
RUN go get -u github.com/golang/protobuf/protoc-gen-go
# Install grpc plugins
RUN git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc && \
cd grpc && \
git submodule update --init && \
for plugin in grpc_php_plugin \
grpc_python_plugin \
grpc_ruby_plugin \
grpc_objective_c_plugin \
grpc_node_plugin \
grpc_csharp_plugin \
grpc_cpp_plugin; \
do make ${plugin}; \
cp bins/opt/${plugin} /usr/local/bin/${plugin} ; \
done && \
cd $GOPATH && \
rm -rf grpc
RUN cp /go/src/google.golang.org/genproto/googleapis/api/annotations/*.pb.go /go/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api/
# Cleanup
RUN apk del $buildDeps && rm -rf /var/cache/apk/*
FROM alpine:3.9
RUN apk update && \
apk add git \
make \
unzip \
g++ \
ca-certificates \
&& rm -rf /var/cache/apk/*
COPY run.sh /run.sh
ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
COPY --from=builder /usr/local/go /usr/local/go
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /usr/local/lib /usr/local/lib
COPY --from=builder /usr/local/include /usr/local/include
COPY --from=builder /go /go
RUN ldconfig /
RUN go version
WORKDIR $GOPATH
ENTRYPOINT ["/run.sh"]