blob: 0d8fadcd598b31ad68ec4d76281ccd59628d90c7 [file] [log] [blame]
# 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
# 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
SHELL ["/bin/bash", "-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/
WORKDIR /app
# -------------
# Image creation stage
FROM ubuntu:hirsute-20220113 AS prod
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN \
apt-get update && \
apt-get install -y \
wget=1.21-1ubuntu3 ca-certificates=20210119ubuntu0.21.04.1 \
libpcre2-8-0=10.36-2ubuntu5 \
libcrypt1=1:4.4.17-1ubuntu3 \
libssh-4=0.9.5-1ubuntu0.1 \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*
# Download and install library packages
RUN \
wget https://github.com/CESNET/libyang/releases/download/v2.0.112/libyang2_2.0.112.1-1_amd64.deb -O libyang2.deb && \
wget https://github.com/sysrepo/sysrepo/releases/download/v2.0.53/libsysrepo6_2.0.53.1-1_amd64.deb -O libsysrepo6.deb && \
wget https://github.com/sysrepo/sysrepo/releases/download/v2.0.53/sysrepo-tools_2.0.53.1-1_amd64.deb -O sysrepo-tools.deb && \
wget https://github.com/CESNET/libnetconf2/releases/download/v2.0.24/libnetconf2-2_2.0.24.1-1_amd64.deb -O libnetconf2-2.deb && \
wget https://github.com/CESNET/netopeer2/releases/download/v2.0.35/netopeer2_2.0.35.2-1_amd64.deb -O netopeer2_2.deb
RUN dpkg -i libyang2.deb libsysrepo6.deb sysrepo-tools.deb libnetconf2-2.deb netopeer2_2.deb
RUN rm libyang2.deb libsysrepo6.deb sysrepo-tools.deb libnetconf2-2.deb netopeer2_2.deb
# Copy yang files and install them to sysrepo
COPY ./build/yang-files /yang
RUN sysrepoctl -a -i /yang/bbf-device-aggregation.yang -s /yang -p 664 -v3
# Add user for connecting to netopeer2-server through ssh
ARG NETCONF_USER=voltha
ARG NETCONF_PASSWORD=onf
RUN useradd -rm -g netconf -u 1001 $NETCONF_USER
RUN echo $NETCONF_USER:$NETCONF_PASSWORD | chpasswd
# Set the working directory
WORKDIR /app
# 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