| # Copyright 2022-present Open Networking Foundation |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| # voltha-northbound-bbf-adapter dockerfile |
| |
| #------------- |
| # Build stage |
| |
| FROM voltha/bbf-adapter-builder:local AS dev |
| |
| #Build runtime dependencies |
| RUN apk add --no-cache libssh-dev=0.9.5-r0 openssl-dev=1.1.1q-r0 openssl=1.1.1q-r0 bash=5.1.16-r0 |
| |
| ARG LIBNETCONF2_VERSION |
| ARG NETOPEER2_VERSION |
| |
| #Build libnetconf2 |
| WORKDIR / |
| RUN git clone https://github.com/CESNET/libnetconf2.git |
| WORKDIR /libnetconf2 |
| RUN git checkout $LIBNETCONF2_VERSION && mkdir build |
| WORKDIR /libnetconf2/build |
| RUN cmake -D CMAKE_BUILD_TYPE:String="Release" .. && \ |
| make && \ |
| make install && \ |
| rm -rf libnetconf2 |
| |
| #Build netopeer2 |
| WORKDIR / |
| RUN git clone https://github.com/CESNET/netopeer2.git |
| WORKDIR /netopeer2 |
| RUN git checkout $NETOPEER2_VERSION && mkdir build |
| WORKDIR /netopeer2/build |
| RUN cmake -D CMAKE_BUILD_TYPE:String="Release" .. && \ |
| make && \ |
| make install && \ |
| rm -rf netopeer2 |
| |
| # Use Standard go build directory structure |
| WORKDIR /go/src |
| COPY . . |
| |
| ARG EXTRA_GO_BUILD_TAGS="" |
| |
| ARG CGO_PARAMETER=1 |
| |
| ARG org_label_schema_version=unknown |
| ARG org_label_schema_vcs_url=unknown |
| ARG org_label_schema_vcs_ref=unknown |
| ARG org_label_schema_build_date=unknown |
| ARG org_opencord_vcs_commit_date=unknown |
| ARG org_opencord_vcs_dirty=unknown |
| |
| # Build bbf-adapter |
| SHELL ["/bin/ash", "-o", "pipefail", "-c"] |
| RUN \ |
| CGO_ENABLED=$CGO_PARAMETER go build $EXTRA_GO_BUILD_TAGS -mod=vendor -o /app/bbf-adapter \ |
| -ldflags \ |
| "-X github.com/opencord/voltha-lib-go/v7/pkg/version.version=$org_label_schema_version \ |
| -X github.com/opencord/voltha-lib-go/v7/pkg/version.vcsRef=$org_label_schema_vcs_ref \ |
| -X github.com/opencord/voltha-lib-go/v7/pkg/version.vcsDirty=$org_opencord_vcs_dirty \ |
| -X github.com/opencord/voltha-lib-go/v7/pkg/version.goVersion=$(go version 2>&1 | sed -E 's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \ |
| -X github.com/opencord/voltha-lib-go/v7/pkg/version.os=$(go env GOHOSTOS) \ |
| -X github.com/opencord/voltha-lib-go/v7/pkg/version.arch=$(go env GOHOSTARCH) \ |
| -X github.com/opencord/voltha-lib-go/v7/pkg/version.buildTime=$org_label_schema_build_date" \ |
| ./cmd/bbf-adapter/ |
| |
| # ------------- |
| # Image creation stage |
| FROM alpine:3.13 AS prod |
| |
| SHELL ["/bin/ash", "-o", "pipefail", "-c"] |
| |
| RUN apk add --no-cache pcre2=10.36-r1 libssh=0.9.5-r0 openssl=1.1.1q-r0 |
| |
| # Dependencies install their library files in lib64, add it to the path |
| RUN echo "/lib:/usr/local/lib:/usr/lib:/usr/local/lib64" > /etc/ld-musl-x86_64.path |
| |
| # Copy dependencies files |
| COPY --from=dev /usr/local/bin /usr/local/bin |
| COPY --from=dev /usr/local/sbin /usr/local/sbin |
| COPY --from=dev /usr/local/lib64 /usr/local/lib64 |
| COPY --from=dev /usr/local/share /usr/local/share |
| COPY --from=dev /etc/sysrepo /etc/sysrepo |
| |
| # Add user for connecting to netopeer2-server through ssh |
| ARG NETCONF_USER=voltha |
| ARG NETCONF_PASSWORD=onf |
| |
| RUN addgroup -S netconf |
| RUN adduser $NETCONF_USER --uid 1001 -G netconf --disabled-password |
| RUN echo $NETCONF_USER:$NETCONF_PASSWORD | chpasswd |
| |
| # Copy yang files and install them to sysrepo |
| COPY ./build/yang-files /yang |
| RUN for f in /yang/*/*.yang; do sysrepoctl -i "$f" -s /yang -o $NETCONF_USER -g netconf -p 664 -v3; done |
| |
| COPY ./build/config /config |
| # Disable nacm to test edit-config easily |
| RUN sysrepocfg --import=/config/nacm.xml -d startup -m ietf-netconf-acm |
| RUN sysrepocfg --import=/config/nacm.xml -d running -m ietf-netconf-acm |
| RUN sysrepocfg --import=/config/nacm.xml -d candidate -m ietf-netconf-acm |
| |
| # Enable admin and oper state in ietf-hardware |
| RUN sysrepoctl -e hardware-state -c ietf-hardware -v3 |
| |
| COPY ./build/yang-files/schema-mount.xml / |
| |
| # Add sysrepo's yang library data to the data provided to the schema-mount libyang extension |
| RUN sysrepocfg -X -x/ietf-yang-library:* -d operational >> /schema-mount.xml |
| |
| # Set the working directory |
| WORKDIR / |
| |
| # Copy required files |
| COPY --from=dev /app/bbf-adapter /app/bbf-adapter |
| |
| # Label image |
| ARG org_label_schema_version=unknown |
| ARG org_label_schema_vcs_url=unknown |
| ARG org_label_schema_vcs_ref=unknown |
| ARG org_label_schema_build_date=unknown |
| ARG org_opencord_vcs_commit_date=unknown |
| ARG org_opencord_vcs_dirty=unknown |
| |
| LABEL \ |
| org.label-schema.schema-version=1.0 \ |
| org.label-schema.name=voltha-northbound-bbf-adapter \ |
| org.label-schema.version=$org_label_schema_version \ |
| org.label-schema.vcs-url=$org_label_schema_vcs_url \ |
| org.label-schema.vcs-ref=$org_label_schema_vcs_ref \ |
| org.label-schema.build-date=$org_label_schema_build_date \ |
| org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date \ |
| org.opencord.vcs-dirty=$org_opencord_vcs_dirty |
| |
| # running netopeer2-server as a standard user is not supported right now |
| # https://github.com/sysrepo/sysrepo/issues/2148#issuecomment-695950173 |