blob: a7526bc1413266433831496df1f40c5775ea21f9 [file] [log] [blame]
Kent Hagermanda41d742020-01-07 14:55:56 -05001# Copyright 2020-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Zack Williams88200d32020-04-02 13:36:41 -070015FROM golang:1.13.9-alpine as build
Kent Hagermanda41d742020-01-07 14:55:56 -050016
17ARG PROTOC_VERSION
Kent Hagermanda41d742020-01-07 14:55:56 -050018ARG PROTOC_SHA256SUM
Kent Hagerman1f99b662020-03-10 17:22:11 -040019ARG PROTOC_GEN_GO_VERSION
20ARG PROTOC_GEN_GRPC_GATEWAY_VERSION
Kent Hagermanda41d742020-01-07 14:55:56 -050021
Andrey Pozolotin49a35452020-08-14 22:14:51 +020022RUN apk add --no-cache libatomic=9.3.0-r0 musl=1.1.24-r2
Kent Hagermanda41d742020-01-07 14:55:56 -050023
24# download & compile this specific version of protoc-gen-go
Kent Hagerman1f99b662020-03-10 17:22:11 -040025RUN GO111MODULE=on CGO_ENABLED=0 go get -u \
26 github.com/golang/protobuf/protoc-gen-go@v$PROTOC_GEN_GO_VERSION \
27 github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v$PROTOC_GEN_GRPC_GATEWAY_VERSION \
28 github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v$PROTOC_GEN_GRPC_GATEWAY_VERSION
Kent Hagermanda41d742020-01-07 14:55:56 -050029
30RUN mkdir -p /tmp/protoc3 && \
31 wget -O /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \
32 [ "$(sha256sum /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip)" = "${PROTOC_SHA256SUM} /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip" ] && \
Kent Hagermand84cc442020-01-29 17:09:14 -050033 unzip /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /tmp/protoc3 && \
34 chmod -R a+rx /tmp/protoc3/
Kent Hagermanda41d742020-01-07 14:55:56 -050035
36
37FROM busybox:1.31.1-glibc
38
39# dynamic libs for protoc
40COPY --from=build /usr/lib/libatomic.so.1 /usr/lib/
41COPY --from=build /lib/libc.musl-x86_64.so.1 /usr/lib/
42ENV LD_LIBRARY_PATH=/usr/lib
43
44# protoc & well-known-type definitions
45COPY --from=build /tmp/protoc3/bin/* /usr/local/bin/
46COPY --from=build /tmp/protoc3/include/ /usr/local/include/
Kent Hagermanda41d742020-01-07 14:55:56 -050047
Kent Hagerman1f99b662020-03-10 17:22:11 -040048# copy protoc-gen-go, protoc-gen-grpc-gateway, and protoc-gen-swagger
Kent Hagermanda41d742020-01-07 14:55:56 -050049COPY --from=build /go/bin/* /usr/local/bin/
50
51WORKDIR /app
52
53# Label image
54ARG org_label_schema_version=unknown
55ARG org_label_schema_vcs_url=unknown
56ARG org_label_schema_vcs_ref=unknown
57ARG org_label_schema_build_date=unknown
58ARG org_opencord_vcs_commit_date=unknown
59ARG org_opencord_vcs_dirty=unknown
60ARG PROTOC_VERSION=unknown
61ARG PROTOC_GEN_GO_VERSION=unknown
Kent Hagerman1f99b662020-03-10 17:22:11 -040062ARG PROTOC_GEN_GRPC_GATEWAY_VERSION=unknown
Kent Hagermanda41d742020-01-07 14:55:56 -050063
64LABEL org.label-schema.schema-version=1.0 \
65 org.label-schema.name=voltha-protoc \
66 org.label-schema.version=$org_label_schema_version \
67 org.label-schema.vcs-url=$org_label_schema_vcs_url \
68 org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
69 org.label-schema.build-date=$org_label_schema_build_date \
70 org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date \
71 org.opencord.vcs-dirty=$org_opencord_vcs_dirty \
72 org.opencord.protoc-version=$PROTOC_VERSION \
Kent Hagerman1f99b662020-03-10 17:22:11 -040073 org.opencord.protoc-gen-go-version=$PROTOC_GEN_GO_VERSION \
74 org.opencord.protoc-gen-grpc-gateway-version=$PROTOC_GEN_GRPC_GATEWAY_VERSION