blob: 3fa0829924507af8b521233be154fe9b959be943 [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
15FROM golang:1.13.5-alpine as build
16
17ARG PROTOC_VERSION
18ARG PROTOC_GEN_GO_VERSION
19ARG PROTOC_SHA256SUM
20
21RUN apk add --no-cache libatomic=9.2.0-r3 musl=1.1.24-r0
22
23# download & compile this specific version of protoc-gen-go
24RUN GO111MODULE=on go get -u github.com/golang/protobuf/protoc-gen-go@v$PROTOC_GEN_GO_VERSION
25
26RUN mkdir -p /tmp/protoc3 && \
27 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 && \
28 [ "$(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 -050029 unzip /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /tmp/protoc3 && \
30 chmod -R a+rx /tmp/protoc3/
Kent Hagermanda41d742020-01-07 14:55:56 -050031
32
33FROM busybox:1.31.1-glibc
34
35# dynamic libs for protoc
36COPY --from=build /usr/lib/libatomic.so.1 /usr/lib/
37COPY --from=build /lib/libc.musl-x86_64.so.1 /usr/lib/
38ENV LD_LIBRARY_PATH=/usr/lib
39
40# protoc & well-known-type definitions
41COPY --from=build /tmp/protoc3/bin/* /usr/local/bin/
42COPY --from=build /tmp/protoc3/include/ /usr/local/include/
Kent Hagermanda41d742020-01-07 14:55:56 -050043
44# copy protoc-gen-go
45COPY --from=build /go/bin/* /usr/local/bin/
46
47WORKDIR /app
48
49# Label image
50ARG org_label_schema_version=unknown
51ARG org_label_schema_vcs_url=unknown
52ARG org_label_schema_vcs_ref=unknown
53ARG org_label_schema_build_date=unknown
54ARG org_opencord_vcs_commit_date=unknown
55ARG org_opencord_vcs_dirty=unknown
56ARG PROTOC_VERSION=unknown
57ARG PROTOC_GEN_GO_VERSION=unknown
58
59LABEL org.label-schema.schema-version=1.0 \
60 org.label-schema.name=voltha-protoc \
61 org.label-schema.version=$org_label_schema_version \
62 org.label-schema.vcs-url=$org_label_schema_vcs_url \
63 org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
64 org.label-schema.build-date=$org_label_schema_build_date \
65 org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date \
66 org.opencord.vcs-dirty=$org_opencord_vcs_dirty \
67 org.opencord.protoc-version=$PROTOC_VERSION \
68 org.opencord.protoc-gen-go-version=$PROTOC_GEN_GO_VERSION