diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..64b15e4 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @jucr-io diff --git a/.github/actions/publish-binaries/action.yaml b/.github/actions/publish-binaries/action.yaml new file mode 100644 index 0000000..92f319a --- /dev/null +++ b/.github/actions/publish-binaries/action.yaml @@ -0,0 +1,49 @@ +name: publish-binaries +description: publish rust binaries +inputs: + os: + description: github action OS + target: + description: rust target + version: + description: release tag + name: + description: release name + bin: + description: rust bin name + + +runs: + using: composite + steps: + - name: setup toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: ${{ inputs.target }} + + - name: set version + shell: bash + run: cargo install cargo-edit && cargo set-version $VERSION + env: + VERSION: ${{ github.ref_name }} + + - name: run build + uses: houseabsolute/actions-rust-cross@v0 + with: + command: "build" + target: ${{ inputs.target }} + toolchain: "stable" + args: "--locked --release" + strip: true + + - name: package + shell: bash + run: | + cd target/${{ inputs.target }}/release + tar czvf ../../../${{ inputs.name }} ${{ inputs.bin }} + cd - + + - name: upload artifacts + uses: softprops/action-gh-release@v2 + with: + files: "pathfinder-*" diff --git a/.github/actions/publish-docker-image/action.yaml b/.github/actions/publish-docker-image/action.yaml new file mode 100644 index 0000000..74591dc --- /dev/null +++ b/.github/actions/publish-docker-image/action.yaml @@ -0,0 +1,60 @@ +name: docker +description: build and publish docker image +inputs: + config-path: + description: The path to the chart-testing configuration file + default: .ct/ct.yaml + name: + description: pathfinder release name + token: + description: github token + +runs: + using: composite + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ inputs.token }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.7.1 + with: + driver-opts: | + image=moby/buildkit:v0.16.0 + + - name: download pathfinder release + id: download_pathfinder + shell: bash + run: | + gh release download -p ${{ inputs.name }} --clobber -O pathfinder.tar.gz + tar -xvf pathfinder.tar.gz + + - name: set docker tags + id: set_tags + shell: bash + run: | + repository_name=${${{ github.repository }}#${{ github.repository_owner }}} + image_name="ghcr.io/${{ github.repository }}" + echo "image_name=$image_name" >> $GITHUB_OUTPUT + echo "repository_name=$repository_name" >> $GITHUB_OUTPUT + + - name: Build and Push Docker Image + uses: docker/build-push-action@v6 + id: docker_build + with: + context: . + github-token: ${{ inputs.token }} + push: true + tags: | + ${{steps.set_tags.outputs.image_name}}:${{ github.sha }} + ${{steps.set_tags.outputs.image_name}}:${{ github.ref_name }} + ${{steps.set_tags.outputs.image_name}}:latest + labels: | + org.opencontainers.image.title=${{ steps.set_tags.outputs.repository_name }} + org.opencontainers.image.source=https://github.com/${{ github.repository }} + platforms: linux/arm64,linux/amd64 + build-args: | + ARG CONFIG=${{ inputs.config-path }} diff --git a/.github/workflows/publish-binaries.yaml b/.github/workflows/publish-binaries.yaml deleted file mode 100644 index 8c3ea2c..0000000 --- a/.github/workflows/publish-binaries.yaml +++ /dev/null @@ -1,74 +0,0 @@ -name: publish-binaries - -on: - release: - types: [released, prereleased] - -permissions: write-all - -jobs: - build: - name: ${{ matrix.platform.target }} - runs-on: ${{ matrix.platform.os }} - if: ${{ !startsWith(github.ref_name, 'v') }} - strategy: - fail-fast: false - matrix: - platform: - - os_name: Linux-x86_64 - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - bin: pathfinder - name: pathfinder-linux-x86_64-gnu.tar.gz - - - os_name: Linux-aarch64-gnu - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - bin: pathfinder - name: pathfinder-linux-aarch64-gnu.tar.gz - - - os_name: macOS-aarch64 - os: macOS-latest - target: aarch64-apple-darwin - bin: pathfinder - name: pathfinder-apple-darwin-aarch64.tar.gz - - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: init cache - uses: Swatinem/rust-cache@v2 - - - name: setup toolchain - run: rustup toolchain install stable --profile minimal - - - name: set version - run: cargo install cargo-edit && cargo set-version $VERSION - env: - VERSION: ${{ github.ref_name }} - - - name: run build - uses: houseabsolute/actions-rust-cross@v0 - with: - command: "build" - target: ${{ matrix.platform.target }} - toolchain: "stable" - args: "--locked --release" - strip: true - - - name: package - shell: bash - run: | - cd target/${{ matrix.platform.target }}/release - if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then - 7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} - else - tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} - fi - cd - - - - name: upload artifacts - uses: softprops/action-gh-release@v2 - with: - files: "pathfinder-*" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..58976cb --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,92 @@ +name: publish pathfinder +on: + release: + types: [released, prereleased] + +permissions: + contents: write + packages: write + id-token: write + +env: + GH_TOKEN: ${{ github.token }} + +jobs: + publish-binaries: + name: ${{ matrix.platform.target }} + runs-on: ${{ matrix.platform.os }} + if: ${{ !startsWith(github.ref_name, 'v') }} + strategy: + fail-fast: false + matrix: + platform: + - os_name: Linux-x86_64 + os: ubuntu-latest + target: x86_64-unknown-linux-gnu + bin: pathfinder + name: pathfinder-linux-x86_64-gnu.tar.gz + + - os_name: Linux-aarch64-gnu + os: ubuntu-latest + target: aarch64-unknown-linux-gnu + bin: pathfinder + name: pathfinder-linux-aarch64-gnu.tar.gz + + - os_name: macOS-aarch64 + os: macOS-latest + target: aarch64-apple-darwin + bin: pathfinder + name: pathfinder-apple-darwin-aarch64.tar.gz + + steps: + - name: checkout + uses: actions/checkout@v4.2.2 + + - name: Install dependencies for Linux + if: matrix.platform.os == 'ubuntu-latest' + run: sudo apt-get update && sudo apt-get install -y libssl-dev + + - name: publish rust binaries + uses: ./.github/actions/publish-binaries + continue-on-error: false + with: + os: ${{ matrix.platform.os }} + version: ${{ github.ref_name }} + target: ${{ matrix.platform.target }} + name: ${{ matrix.platform.name }} + bin: ${{ matrix.platform.bin }} + + + build-and-push-docker-image: + needs: [publish-binaries] + name: ${{ matrix.platform.target }} + runs-on: ${{ matrix.platform.os }} + strategy: + fail-fast: false + matrix: + platform: + - os_name: Linux-x86_64 + os: ubuntu-latest + target: x86_64-unknown-linux-gnu + bin: pathfinder + name: pathfinder-linux-x86_64-gnu.tar.gz + platform: linux/amd64 + + - os_name: Linux-aarch64-gnu + os: ubuntu-latest + target: aarch64-unknown-linux-gnu + bin: pathfinder + name: pathfinder-linux-aarch64-gnu.tar.gz + platform: linux/arm64 + + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + - name: Build and push Docker image + uses: ./.github/actions/publish-docker-image + with: + config-path: 'example-config.yaml' + name: ${{ matrix.platform.name }} + token: ${{ github.token }} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 4904e78..bfc47ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,9 @@ rand = { version = "0.8.5" } [dependencies] anyhow = "1.0.86" futures-util = "0.3.30" -rdkafka = { version = "0.36.2", features = ["ssl-vendored"] } +openssl = { version = "0.10", features = ["vendored"] } +openssl-sys = { version = "0.9", features = ["vendored"] } +rdkafka = { version = "0.36.2", features = ["cmake-build"] } tokio = { version = "1.39.2", features = ["full"] } tokio-util = { version = "0.7.11", features = ["rt"] } tokio-macros = "2.4.0" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..323e5d6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM debian:bullseye-slim AS build + +RUN apt-get update && apt-get install -y unzip curl + +ARG CONFIG=example-config.yaml +COPY $CONFIG /config.yaml +COPY pathfinder . + +RUN cp pathfinder /usr/local/bin/pathfinder + +FROM debian:bullseye-slim + +RUN apt-get update && apt-get install -y libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/* + +COPY --from=build /usr/local/bin/pathfinder /usr/local/bin/pathfinder + +COPY --from=build /config.yaml /etc/pf-config.yaml + +ENTRYPOINT ["/usr/local/bin/pathfinder", "--config-path", "/etc/pf-config.yaml", "listen"] \ No newline at end of file