Elia Battiston | ac8d23f | 2022-03-14 17:54:56 +0100 | [diff] [blame] | 1 | # 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 Battiston | f9e12e6 | 2022-04-01 12:45:37 +0200 | [diff] [blame] | 18 | # ------------- |
| 19 | # Build golangci-lint |
| 20 | FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS lint-builder |
| 21 | |
Elia Battiston | 4750d3c | 2022-07-14 13:24:56 +0000 | [diff] [blame] | 22 | RUN apk add --no-cache build-base=0.5-r3 |
Elia Battiston | f9e12e6 | 2022-04-01 12:45:37 +0200 | [diff] [blame] | 23 | |
| 24 | #Install golangci-lint |
| 25 | RUN 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 Battiston | b244bb5 | 2022-03-24 15:47:16 +0100 | [diff] [blame] | 30 | FROM --platform=linux/amd64 golang:1.16.3-alpine3.13 AS dev |
Elia Battiston | ac8d23f | 2022-03-14 17:54:56 +0100 | [diff] [blame] | 31 | |
| 32 | RUN mkdir -m 777 /.cache /go/pkg |
| 33 | |
Elia Battiston | 4750d3c | 2022-07-14 13:24:56 +0000 | [diff] [blame] | 34 | RUN apk add --no-cache build-base=0.5-r3 pcre2-dev=10.36-r1 git=2.30.5-r0 cmake=3.18.4-r1 |
Elia Battiston | b244bb5 | 2022-03-24 15:47:16 +0100 | [diff] [blame] | 35 | |
Elia Battiston | f9e12e6 | 2022-04-01 12:45:37 +0200 | [diff] [blame] | 36 | # Dependencies install their library files in lib64, add it to the path |
| 37 | RUN echo "/lib:/usr/local/lib:/usr/lib:/usr/local/lib64" > /etc/ld-musl-x86_64.path |
Elia Battiston | ac8d23f | 2022-03-14 17:54:56 +0100 | [diff] [blame] | 38 | |
Elia Battiston | f9e12e6 | 2022-04-01 12:45:37 +0200 | [diff] [blame] | 39 | # Get golangci-lint binary from its builder |
| 40 | COPY --from=lint-builder /go/bin/golangci-lint /usr/bin/ |
Elia Battiston | ac8d23f | 2022-03-14 17:54:56 +0100 | [diff] [blame] | 41 | |
Elia Battiston | b244bb5 | 2022-03-24 15:47:16 +0100 | [diff] [blame] | 42 | ARG LIBYANG_VERSION |
| 43 | ARG SYSREPO_VERSION |
Elia Battiston | ac8d23f | 2022-03-14 17:54:56 +0100 | [diff] [blame] | 44 | |
Elia Battiston | f9e12e6 | 2022-04-01 12:45:37 +0200 | [diff] [blame] | 45 | #Build compile time dependencies |
| 46 | |
Elia Battiston | b244bb5 | 2022-03-24 15:47:16 +0100 | [diff] [blame] | 47 | #Build libyang |
| 48 | WORKDIR / |
| 49 | RUN git clone https://github.com/CESNET/libyang.git |
| 50 | WORKDIR /libyang |
| 51 | RUN git checkout $LIBYANG_VERSION && mkdir build |
| 52 | WORKDIR /libyang/build |
| 53 | RUN cmake -D CMAKE_BUILD_TYPE:String="Release" .. && \ |
| 54 | make && \ |
Elia Battiston | f9e12e6 | 2022-04-01 12:45:37 +0200 | [diff] [blame] | 55 | make install && \ |
| 56 | rm -rf libyang |
Elia Battiston | ac8d23f | 2022-03-14 17:54:56 +0100 | [diff] [blame] | 57 | |
Elia Battiston | b244bb5 | 2022-03-24 15:47:16 +0100 | [diff] [blame] | 58 | #Build sysrepo |
| 59 | WORKDIR / |
| 60 | RUN git clone https://github.com/sysrepo/sysrepo.git |
| 61 | WORKDIR /sysrepo |
| 62 | RUN git checkout $SYSREPO_VERSION && mkdir build |
| 63 | WORKDIR /sysrepo/build |
| 64 | RUN cmake -D CMAKE_BUILD_TYPE:String="Release" .. && \ |
| 65 | make && \ |
Elia Battiston | f9e12e6 | 2022-04-01 12:45:37 +0200 | [diff] [blame] | 66 | make install && \ |
| 67 | rm -rf sysrepo |
Elia Battiston | ac8d23f | 2022-03-14 17:54:56 +0100 | [diff] [blame] | 68 | |
| 69 | WORKDIR /app |
| 70 | |
| 71 | ARG org_label_schema_version=unknown |
| 72 | ARG org_label_schema_vcs_url=unknown |
| 73 | ARG org_label_schema_vcs_ref=unknown |
| 74 | ARG org_label_schema_build_date=unknown |
| 75 | ARG org_opencord_vcs_commit_date=unknown |
| 76 | ARG org_opencord_vcs_dirty=unknown |
| 77 | |
| 78 | LABEL \ |
| 79 | org.label-schema.schema-version=1.0 \ |
| 80 | org.label-schema.name=voltha-northbound-bbf-adapter \ |
| 81 | org.label-schema.version=$org_label_schema_version \ |
| 82 | org.label-schema.vcs-url=$org_label_schema_vcs_url \ |
| 83 | org.label-schema.vcs-ref=$org_label_schema_vcs_ref \ |
| 84 | org.label-schema.build-date=$org_label_schema_build_date \ |
| 85 | org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date \ |
Girish Gowdra | d10fe3c | 2022-05-06 11:22:12 -0700 | [diff] [blame] | 86 | org.opencord.vcs-dirty=$org_opencord_vcs_dirty |