diff --git a/.github/workflows/build-develop.yml b/.github/workflows/build-develop.yml index ec63dd70d..e841417d2 100644 --- a/.github/workflows/build-develop.yml +++ b/.github/workflows/build-develop.yml @@ -379,7 +379,7 @@ jobs: build-app-image-x64: needs: [ package-amd64 ] runs-on: ubuntu-latest - if: github.event_name != 'pull_request' + #if: github.event_name != 'pull_request' steps: - uses: actions/checkout@v3 @@ -412,29 +412,22 @@ jobs: run: | echo "REF_TAG=latest-develop" >> $GITHUB_ENV echo "PRERELEASE=true" >> $GITHUB_ENV - echo "DRAFT=false" >> $GITHUB_ENV - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.ORB_DOCKERHUB_USERNAME }} - password: ${{ secrets.ORB_DOCKERHUB_TOKEN }} + echo "DRAFT=false" >> $GITHUB_ENV - - name: Build + push - pktvisor-cli - env: - CLI_BINARY: pktvisor-cli - IMAGE_NAME: orbcommunity/pktvisor-cli + - name: Prepare version file run: | - docker build . --file docker/Dockerfile.pktvisor-cli --tag ${{ env.IMAGE_NAME }}:${{ env.VERSION }} --tag ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }} - docker push -a ${{ env.IMAGE_NAME }} - echo "CONT_ID=$(docker create --name ${{ env.CLI_BINARY }}-slim-tmp ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }})" >> $GITHUB_ENV + cp -rpf golang/pkg/client/version.go . - - name: Extract static pktvisor-cli asset - env: - CLI_BINARY: pktvisor-cli - IMAGE_NAME: orbcommunity/pktvisor-cli + - name: Build pktvisor-cli + uses: ./.github/actions/build-go + with: + context: "." + file: "./Dockerfile" + + - name: Debug and Rename artifacts run: | - docker cp ${{ env.CONT_ID }}:/${{ env.CLI_BINARY }} ${{github.workspace}}/${{ env.CLI_BINARY }}-linux-x86_64-${{ env.VERSION }} + ls -lha . + mv pktvisor-cli pktvisor-cli-linux-x86_64-${{ env.VERSION }} - name: Upload pktvisor-cli artifact env: @@ -443,6 +436,12 @@ jobs: with: name: ${{ env.BINARY_NAME }} path: ${{github.workspace}}/${{ env.BINARY_NAME }} + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.ORB_DOCKERHUB_USERNAME }} + password: ${{ secrets.ORB_DOCKERHUB_TOKEN }} - name: Build + push - pktvisor-prom-write env: diff --git a/.github/workflows/cross.yml b/.github/workflows/build_cross.yml similarity index 99% rename from .github/workflows/cross.yml rename to .github/workflows/build_cross.yml index a0546fada..6fa2c8a0b 100644 --- a/.github/workflows/cross.yml +++ b/.github/workflows/build_cross.yml @@ -6,11 +6,11 @@ on: pull_request: branches: - develop - #- release + push: branches: - develop - #- release + jobs: pkvisor: @@ -47,6 +47,7 @@ jobs: with: path: bin/sccache key: sccache-v0.2.15 + - name: Install sccache if: steps.cache-sccache.outputs.cache-hit != 'true' run: | @@ -61,6 +62,7 @@ jobs: with: path: toolchain key: toolchain-test-${{matrix.toolchain}} + - name: Install compiler toolchain if: steps.cache-toolchain.outputs.cache-hit != 'true' run: | @@ -69,6 +71,7 @@ jobs: - name: Install Conan run: pip install --no-cache-dir 'conan==1.59.0' --force-reinstall + - name: Create Conan configuration run: | # init config @@ -76,6 +79,7 @@ jobs: conan config set general.revisions_enabled=1 # add custom compiler settings for libc python3 -c 'import yaml; p = "${{env.CONAN_USER_HOME}}/.conan/settings.yml"; d = yaml.safe_load(open(p)); d["compiler"]["gcc"]["libc"] = ["None", "glibc", "musl"]; yaml.safe_dump(d, open(p, "w"))' + - name: Create Conan host profile run: | cat > "${{env.CONAN_USER_HOME}}/.conan/profiles/host" << "EOF" @@ -109,14 +113,17 @@ jobs: uses: actions/checkout@v3 with: path: src + - name: Remove crashpad from conanfile run: | sed -i -e "s/crashpad.*//g" ${{github.workspace}}/src/conanfile.txt + - name: Install dependencies run: | mkdir build cd build conan install -pr:b default -pr:h host -g virtualenv --build=missing "${{github.workspace}}/src" + - name: Configure run: | cd build @@ -131,6 +138,7 @@ jobs: -DProtobuf_PROTOC_EXECUTABLE=$(command -v protoc) \ -DCORRADE_RC_PROGRAM=$(command -v corrade-rc) \ -DCMAKE_CXX_STANDARD_LIBRARIES=-latomic + - name: Build run: | cd build @@ -173,15 +181,17 @@ jobs: uses: actions/checkout@v3 with: path: src + - name: Configure run: | VERSION_ONLY=1 cmake src + - name: Build run: | if [ "${{matrix.os}}" = macos ]; then export GOOS=darwin fi - + if [ "${{matrix.arch}}" = armv7lh ]; then export GOARCH=arm elif [ "${{matrix.arch}}" = aarch64 ]; then @@ -190,6 +200,7 @@ jobs: cd src/golang go build -o ${{github.workspace}}/pktvisor-cli ./cmd/pktvisor-cli + - name: Upload pktvisor-cli uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/debug_build.yml b/.github/workflows/build_debug.yml similarity index 100% rename from .github/workflows/debug_build.yml rename to .github/workflows/build_debug.yml diff --git a/docker/Dockerfile.debug b/docker/Dockerfile.debug deleted file mode 100644 index 27ba07c27..000000000 --- a/docker/Dockerfile.debug +++ /dev/null @@ -1,56 +0,0 @@ -FROM debian:bullseye-slim AS cppbuild - -ENV BUILD_DEPS "g++ cmake make git pkgconf jq python3-pip python3-setuptools ca-certificates libasan6" - -RUN \ - apt-get update && \ - apt-get upgrade --yes --force-yes && \ - apt-get install --yes --force-yes --no-install-recommends ${BUILD_DEPS} && \ - pip3 install conan - -# need git for current hash for VERSION -COPY ./.git/ /pktvisor-src/.git/ -COPY ./src/ /pktvisor-src/src/ -COPY ./cmd/ /pktvisor-src/cmd/ -COPY ./3rd/ /pktvisor-src/3rd/ -COPY ./docker/ /pktvisor-src/docker/ -COPY ./golang/ /pktvisor-src/golang/ -COPY ./integration_tests/ /pktvisor-src/integration_tests/ -COPY ./cmake/ /pktvisor-src/cmake/ -COPY ./CMakeLists.txt /pktvisor-src/ -COPY ./conanfile.txt /pktvisor-src/ - -WORKDIR /tmp/build -RUN \ - conan profile new --detect default && \ - conan profile update settings.compiler.libcxx=libstdc++11 default && \ - conan config set general.revisions_enabled=1 - -RUN \ - PKG_CONFIG_PATH=/local/lib/pkgconfig cmake -DCMAKE_BUILD_TYPE=Debug -DASAN=ON /pktvisor-src && \ - make all -j 4 - -FROM golang:latest AS gobuild -COPY golang/ /src/ -WORKDIR /src/ -COPY --from=cppbuild /pktvisor-src/golang/pkg/client/version.go /src/pkg/client/version.go -RUN go build -o pktvisor-cli cmd/pktvisor-cli/main.go - -FROM debian:bullseye-slim AS runtime - -ENV RUNTIME_DEPS "curl ca-certificates libasan6 gdb" - -RUN \ - apt-get update && \ - apt-get upgrade --yes --force-yes && \ - apt-get install --yes --force-yes --no-install-recommends ${RUNTIME_DEPS} && \ - rm -rf /var/lib/apt - -COPY --from=cppbuild /tmp/build/bin/pktvisord /usr/local/sbin/pktvisord -COPY --from=cppbuild /tmp/build/bin/pktvisor-reader /usr/local/sbin/pktvisor-reader -COPY --from=gobuild /src/pktvisor-cli /usr/local/bin/pktvisor-cli -COPY docker/entry.sh /entry.sh -RUN chmod a+x /entry.sh - -ENTRYPOINT [ "/entry.sh" ] - diff --git a/docker/Makefile b/docker/Makefile index 71e4b254f..bfabf258a 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -1,7 +1,7 @@ -.PHONY: clang-toolchain +.PHONY: pktvisor # for developer environments (e.g. clion docker toolchain) # note does not require/include the source base -clang-toolchain: - docker build --build-arg UID=$(shell id -u) -t pktvisor/clang-toolchain -f Dockerfile.clang-toolchain . +pktvisor: + docker build -t orbcommunity/pktvisor -f ./Dockerfile .. diff --git a/docker/entry.sh b/docker/entry.sh deleted file mode 100755 index e6401a2ae..000000000 --- a/docker/entry.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# this is the entry point to the docker container, and is only used there - -set -e - -export PATH=$PATH:/usr/local/bin/:/usr/local/sbin/ - -if [ $# -eq 0 ]; then - echo "No arguments provided: specify either 'pktvisor-cli', 'pktvisor-reader' or 'pktvisord'. Try:" - echo "docker run orbcommunity/pktvisor pktvisor-cli -h" - echo "docker run orbcommunity/pktvisor pktvisor-reader --help" - echo "docker run orbcommunity/pktvisor pktvisord --help" - exit 1 -fi - -# backwards compatibility -BINARY="$1" -if [ "$BINARY" = 'pktvisor' ]; then - BINARY='pktvisor-cli' -fi - -if [ "$BINARY" = 'pktvisor-pcap' ]; then - BINARY='pktvisor-reader' -fi - -# Add sleep to allow tty to be ready for Docker when using -it -if [ "$BINARY" = 'pktvisor-cli' ]; then - sleep 1 -fi - -shift -exec "$BINARY" "$@"