blob: a3c27c3f49c655c2e4bc866ea776e57784559ea4 [file] [log] [blame]
Elia Battistonac8d23f2022-03-14 17:54:56 +01001# Copyright 2022-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
15# Dockerfile with golang and the sysrepo dependencies for voltha-northbound-bff-adapter
16# This image is used for testing, static code analysis and building
17
Elia Battistonf9e12e62022-04-01 12:45:37 +020018# -------------
19# Build golangci-lint
20FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS lint-builder
21
22RUN apk add --no-cache build-base=0.5-r2
23
24#Install golangci-lint
25RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.44.2
26
27# -------------
28# Create the builder and tools image for the bbf adapter
29
Elia Battistonb244bb52022-03-24 15:47:16 +010030FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS dev
Elia Battistonac8d23f2022-03-14 17:54:56 +010031
32RUN mkdir -m 777 /.cache /go/pkg
33
Girish Gowdrad10fe3c2022-05-06 11:22:12 -070034RUN apk add --no-cache build-base=0.5-r2 pcre2-dev=10.36-r0 git=2.30.3-r0 cmake=3.18.4-r1
Elia Battistonb244bb52022-03-24 15:47:16 +010035
Elia Battistonf9e12e62022-04-01 12:45:37 +020036# Dependencies install their library files in lib64, add it to the path
37RUN echo "/lib:/usr/local/lib:/usr/lib:/usr/local/lib64" > /etc/ld-musl-x86_64.path
Elia Battistonac8d23f2022-03-14 17:54:56 +010038
Elia Battistonf9e12e62022-04-01 12:45:37 +020039# Get golangci-lint binary from its builder
40COPY --from=lint-builder /go/bin/golangci-lint /usr/bin/
Elia Battistonac8d23f2022-03-14 17:54:56 +010041
Elia Battistonb244bb52022-03-24 15:47:16 +010042ARG LIBYANG_VERSION
43ARG SYSREPO_VERSION
Elia Battistonac8d23f2022-03-14 17:54:56 +010044
Elia Battistonf9e12e62022-04-01 12:45:37 +020045#Build compile time dependencies
46
Elia Battistonb244bb52022-03-24 15:47:16 +010047#Build libyang
48WORKDIR /
49RUN git clone https://github.com/CESNET/libyang.git
50WORKDIR /libyang
51RUN git checkout $LIBYANG_VERSION && mkdir build
52WORKDIR /libyang/build
53RUN cmake -D CMAKE_BUILD_TYPE:String="Release" .. && \
54 make && \
Elia Battistonf9e12e62022-04-01 12:45:37 +020055 make install && \
56 rm -rf libyang
Elia Battistonac8d23f2022-03-14 17:54:56 +010057
Elia Battistonb244bb52022-03-24 15:47:16 +010058#Build sysrepo
59WORKDIR /
60RUN git clone https://github.com/sysrepo/sysrepo.git
61WORKDIR /sysrepo
62RUN git checkout $SYSREPO_VERSION && mkdir build
63WORKDIR /sysrepo/build
64RUN cmake -D CMAKE_BUILD_TYPE:String="Release" .. && \
65 make && \
Elia Battistonf9e12e62022-04-01 12:45:37 +020066 make install && \
67 rm -rf sysrepo
Elia Battistonac8d23f2022-03-14 17:54:56 +010068
69WORKDIR /app
70
71ARG org_label_schema_version=unknown
72ARG org_label_schema_vcs_url=unknown
73ARG org_label_schema_vcs_ref=unknown
74ARG org_label_schema_build_date=unknown
75ARG org_opencord_vcs_commit_date=unknown
76ARG org_opencord_vcs_dirty=unknown
77
78LABEL \
79org.label-schema.schema-version=1.0 \
80org.label-schema.name=voltha-northbound-bbf-adapter \
81org.label-schema.version=$org_label_schema_version \
82org.label-schema.vcs-url=$org_label_schema_vcs_url \
83org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
84org.label-schema.build-date=$org_label_schema_build_date \
85org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date \
Girish Gowdrad10fe3c2022-05-06 11:22:12 -070086org.opencord.vcs-dirty=$org_opencord_vcs_dirty