From: Ed Warnicke Date: Tue, 26 Apr 2022 23:57:24 +0000 (-0500) Subject: Add Dockerfile to ease generation of binapi/ X-Git-Tag: v0.5.0~11 X-Git-Url: https://gerrit.fd.io/r/gitweb?p=govpp.git;a=commitdiff_plain;h=020d8b00b60f80cccc902da6827c8b8687247b9a Add Dockerfile to ease generation of binapi/ Signed-off-by: Ed Warnicke Change-Id: I2ca5fce1717c798348bb128d5252050cf78b0df2 Signed-off-by: Ed Warnicke --- diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d83f491 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +ARG VPP_VERSION=v21.06 +ARG UBUNTU_VERSION=20.04 + +FROM ubuntu:${UBUNTU_VERSION} as vppbuild +ARG VPP_VERSION +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive TZ=US/Central apt-get install -y git make python3 sudo asciidoc +RUN git clone https://github.com/FDio/vpp.git +WORKDIR /vpp +RUN git checkout ${VPP_VERSION} +#COPY patch/ patch/ +#RUN test -x "patch/patch.sh" && ./patch/patch.sh || exit 1 +RUN DEBIAN_FRONTEND=noninteractive TZ=US/Central UNATTENDED=y make install-dep +RUN make pkg-deb +RUN ./src/scripts/version > /vpp/VPP_VERSION + +FROM vppbuild as vppinstall +#COPY --from=vppbuild /var/lib/apt/lists/* /var/lib/apt/lists/ +#COPY --from=vppbuild [ "/vpp/build-root/libvppinfra_*_amd64.deb", "/vpp/build-root/vpp_*_amd64.deb", "/vpp/build-root/vpp-plugin-core_*_amd64.deb", "/vpp/build-root/vpp-plugin-dpdk_*_amd64.deb", "/pkg/"] +#RUN VPP_INSTALL_SKIP_SYSCTL=false apt install -f -y --no-install-recommends /pkg/*.deb ca-certificates iputils-ping iproute2 tcpdump; \ +# rm -rf /var/lib/apt/lists/*; \ +# rm -rf /pkg +RUN VPP_INSTALL_SKIP_SYSCTL=false apt install -f -y --no-install-recommends /vpp/build-root/*.deb ca-certificates iputils-ping iproute2 tcpdump; \ + rm -rf /var/lib/apt/lists/*; \ + rm -rf /pkg + +FROM golang:1.17.9-alpine3.15 as binapi-generator +ENV GO111MODULE=on +ENV CGO_ENABLED=0 +ENV GOBIN=/bin +ARG GOVPP_VERSION +COPY . /govpp +WORKDIR /govpp +RUN go build -o /bin/binapi-generator ./cmd/binapi-generator + +FROM binapi-generator as gen +COPY --from=vppinstall /usr/share/vpp/api/ /usr/share/vpp/api/ +COPY --from=vppinstall /vpp/VPP_VERSION /VPP_VERSION +WORKDIR /gen/binapi +CMD VPP_VERSION=$(cat /VPP_VERSION) go generate . diff --git a/gen.go b/gen.go new file mode 100644 index 0000000..a15707b --- /dev/null +++ b/gen.go @@ -0,0 +1,19 @@ +// Copyright (c) 2020 Cisco and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// 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. + +package govpp + +//go:generate bash -c "docker run -e PKGPREFIX=$(go list)/binapi -v $(go list -f '{{ .Dir }}'):/gen $(docker build . -q --build-arg GOVPP_VERSION=$(go list -m -f '{{ .Version }}' git.fd.io/govpp.git))"