-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from ns1labs/feature/clang-toolchain
clang toolchain builds, statically linked executables
- Loading branch information
Showing
18 changed files
with
340 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,28 +39,11 @@ jobs: | |
# uses: turtlebrowser/get-conan@4dc7e6dd45c8b1e02e909979d7cfc5ebba6ddbe2 | ||
uses: turtlebrowser/[email protected] | ||
|
||
- name: Conan profile and settings | ||
run: | | ||
conan profile new --detect default | ||
conan config set general.revisions_enabled=1 | ||
- name: Conan profile (linux-workaround) | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | ||
conan profile update settings.compiler.libcxx=libstdc++11 default | ||
|
||
- name: Conan install (osx-workaround) | ||
if: matrix.os == 'macos-latest' | ||
working-directory: ${{github.workspace}}/build | ||
run: | | ||
conan remote add ns1labs-conan https://ns1labs.jfrog.io/artifactory/api/conan/ns1labs-conan | ||
conan install --build=missing .. | ||
- name: linux package install | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install --yes --no-install-recommends golang ca-certificates jq | ||
sudo apt-get install --yes --no-install-recommends jq | ||
- name: Configure CMake | ||
# Use a bash shell so we can use the same syntax for environment variable | ||
|
@@ -100,12 +83,6 @@ jobs: | |
- name: Get Conan | ||
uses: turtlebrowser/[email protected] | ||
|
||
- name: Conan profile and settings | ||
run: | | ||
conan profile new --detect default | ||
conan config set general.revisions_enabled=1 | ||
conan profile update settings.compiler.libcxx=libstdc++11 default | ||
- name: Configure CMake to generate VERSION | ||
shell: bash | ||
working-directory: ${{github.workspace}}/build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
name: Static Build | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- develop | ||
- release | ||
push: | ||
branches: | ||
- develop | ||
- release | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Release | ||
|
||
jobs: | ||
build: | ||
# The CMake configure and build commands are platform agnostic and should work equally | ||
# well on Windows or Mac. You can convert this to a matrix build if you need | ||
# cross-platform coverage. | ||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build and test static base | ||
run: | | ||
docker build -f docker/Dockerfile.static-base -t ns1labs/static-base . | ||
- name: Get branch name | ||
shell: bash | ||
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV | ||
|
||
- name: Debug branch name | ||
run: echo ${{ env.BRANCH_NAME }} | ||
|
||
- name: Get VERSION | ||
run: | | ||
echo "VERSION=`docker run --rm -a stdout --entrypoint cat ns1labs/static-base VERSION`" >> $GITHUB_ENV | ||
- name: Debug version | ||
run: echo ${{ env.VERSION }} | ||
|
||
- name: Generate ref tag (master) | ||
if: github.event_name != 'pull_request' && ${{ env.BRANCH_NAME == 'master' }} | ||
run: | | ||
echo "REF_TAG=latest" >> $GITHUB_ENV | ||
- name: Generate ref tag (develop) | ||
if: github.event_name != 'pull_request' && ${{ env.BRANCH_NAME == 'develop' }} | ||
run: | | ||
echo "REF_TAG=latest-develop" >> $GITHUB_ENV | ||
- name: Generate ref tag (release candidate) | ||
if: github.event_name != 'pull_request' && ${{ env.BRANCH_NAME == 'release' }} | ||
run: | | ||
echo "REF_TAG=latest-rc" >> $GITHUB_ENV | ||
- name: Debug ref tag | ||
if: github.event_name != 'pull_request' | ||
run: echo ${{ env.REF_TAG }} | ||
|
||
- name: Login to Docker Hub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push static pktvisord container | ||
if: github.event_name != 'pull_request' | ||
env: | ||
BASE_BINARY: pktvisord | ||
IMAGE_NAME: ns1labs/pktvisord-slim | ||
run: | | ||
docker build -f docker/Dockerfile.${{ env.BASE_BINARY }}-static -t ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }} -t ${{ env.IMAGE_NAME }}:${{ env.VERSION }} . | ||
docker push -a ${{ env.IMAGE_NAME }} | ||
echo "CONT_ID=$(docker create --name ${{ env.BASE_BINARY }}-slim-tmp ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }})" >> $GITHUB_ENV | ||
- name: Extract static pktvisord asset | ||
if: github.event_name != 'pull_request' | ||
env: | ||
BASE_BINARY: pktvisord | ||
IMAGE_NAME: ns1labs/pktvisord-slim | ||
run: | | ||
docker cp ${{ env.CONT_ID }}:/${{ env.BASE_BINARY }} ${{github.workspace}}/${{ env.BASE_BINARY }}-linux-x86_64-${{ env.VERSION }} | ||
- name: Upload pktvisord artifact | ||
if: github.event_name != 'pull_request' | ||
env: | ||
BINARY_NAME: pktvisord-linux-x86_64-${{ env.VERSION }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ env.BINARY_NAME }} | ||
path: ${{github.workspace}}/${{ env.BINARY_NAME }} | ||
|
||
- name: Build and push static pktvisor-pcap container | ||
if: github.event_name != 'pull_request' | ||
env: | ||
BASE_BINARY: pktvisor-pcap | ||
IMAGE_NAME: ns1labs/pktvisor-pcap-slim | ||
run: | | ||
docker build -f docker/Dockerfile.${{ env.BASE_BINARY }}-static -t ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }} -t ${{ env.IMAGE_NAME }}:${{ env.VERSION }} . | ||
docker push -a ${{ env.IMAGE_NAME }} | ||
echo "CONT_ID=$(docker create --name ${{ env.BASE_BINARY }}-slim-tmp ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }})" >> $GITHUB_ENV | ||
- name: Extract static pktvisor-pcap asset | ||
if: github.event_name != 'pull_request' | ||
env: | ||
BASE_BINARY: pktvisor-pcap | ||
IMAGE_NAME: ns1labs/pktvisor-pcap-slim | ||
run: | | ||
docker cp ${{ env.CONT_ID }}:/${{ env.BASE_BINARY }} ${{github.workspace}}/${{ env.BASE_BINARY }}-linux-x86_64-${{ env.VERSION }} | ||
- name: Upload pktvisor-pcap artifact | ||
if: github.event_name != 'pull_request' | ||
env: | ||
BINARY_NAME: pktvisor-pcap-linux-x86_64-${{ env.VERSION }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ env.BINARY_NAME }} | ||
path: ${{github.workspace}}/${{ env.BINARY_NAME }} | ||
|
||
|
||
- name: Build and push static pktvisor-dnstap container | ||
if: github.event_name != 'pull_request' | ||
env: | ||
BASE_BINARY: pktvisor-dnstap | ||
IMAGE_NAME: ns1labs/pktvisor-dnstap-slim | ||
run: | | ||
docker build -f docker/Dockerfile.${{ env.BASE_BINARY }}-static -t ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }} -t ${{ env.IMAGE_NAME }}:${{ env.VERSION }} . | ||
docker push -a ${{ env.IMAGE_NAME }} | ||
echo "CONT_ID=$(docker create --name ${{ env.BASE_BINARY }}-slim-tmp ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }})" >> $GITHUB_ENV | ||
- name: Extract static pktvisor-dnstap asset | ||
if: github.event_name != 'pull_request' | ||
env: | ||
BASE_BINARY: pktvisor-dnstap | ||
IMAGE_NAME: ns1labs/pktvisor-dnstap-slim | ||
run: | | ||
docker cp ${{ env.CONT_ID }}:/${{ env.BASE_BINARY }} ${{github.workspace}}/${{ env.BASE_BINARY }}-linux-x86_64-${{ env.VERSION }} | ||
- name: Upload pktvisor-dnstap artifact | ||
if: github.event_name != 'pull_request' | ||
env: | ||
BINARY_NAME: pktvisor-dnstap-linux-x86_64-${{ env.VERSION }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ env.BINARY_NAME }} | ||
path: ${{github.workspace}}/${{ env.BINARY_NAME }} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ target_link_libraries(pktvisor-dnstap | |
PRIVATE | ||
${CONAN_LIBS_DOCOPT.CPP} | ||
${VISOR_STATIC_PLUGINS} | ||
${STATIC_FLAGS} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ target_link_libraries(pktvisor-pcap | |
PRIVATE | ||
${CONAN_LIBS_DOCOPT.CPP} | ||
${VISOR_STATIC_PLUGINS} | ||
${STATIC_FLAGS} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ target_link_libraries(pktvisord | |
${CONAN_LIBS_DOCOPT.CPP} | ||
Visor::Core | ||
${VISOR_STATIC_PLUGINS} | ||
${STATIC_FLAGS} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM ns1labs/clang-toolchain:latest | ||
ARG REQUIRE="make cmake python3 py3-pip perl git bash libexecinfo-static libexecinfo-dev" | ||
ARG UID=1000 | ||
|
||
RUN adduser -u ${UID} -D builder | ||
|
||
RUN apk add --no-cache ${REQUIRE} | ||
|
||
RUN ln -s /usr/local/bin/clang /usr/local/bin/cc \ | ||
&& ln -s /usr/local/bin/clang /usr/local/bin/gcc \ | ||
&& ln -s /usr/local/bin/clang++ /usr/local/bin/c++ \ | ||
&& ln -s /usr/local/bin/clang++ /usr/local/bin/g++ \ | ||
&& ln -s /usr/local/bin/clang-cpp /usr/local/bin/cpp \ | ||
&& pip install conan | ||
|
||
USER builder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM ns1labs/static-base AS cppbuild | ||
|
||
FROM scratch AS runtime | ||
|
||
COPY --from=cppbuild /tmp/build/bin/pktvisor-dnstap /pktvisor-dnstap | ||
|
||
ENTRYPOINT [ "/pktvisor-dnstap" ] |
Oops, something went wrong.