Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 191 additions & 0 deletions .github/workflows/build-assets-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: Build Dev Assets

permissions:
pull-requests: write
contents: write

on:
pull_request:
branches:
- docker-dev

env:
INTERPRETER: "3.12"
RUSTFLAGS: "-C debuginfo=0"
BINARY_NAME: "scouter-server"

jobs:
build:
name: build - ${{ matrix.target }} - ${{ matrix.feature }} - ${{ matrix.tag }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04-arm
target: aarch64-unknown-linux-gnu
archive_ext: tar.gz
container_image: rockylinux:9
tag: rocky
archive_name_suffix: -rocky
feature: kafka

- os: ubuntu-22.04-arm
target: aarch64-unknown-linux-gnu
archive_ext: tar.gz
container_image: null
tag: ubuntu
archive_name_suffix: ""
feature: kafka

runs-on: ${{ matrix.os}}
container: ${{ matrix.container_image != null && matrix.container_image || null }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Rocky Deps
if: matrix.container_image == 'rockylinux:9'
run: |
dnf install -y --allowerasing gcc make curl pkgconf openssl-devel wget perl pkg-config

# Install Rust via rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Add Rust to PATH for subsequent steps
echo "$HOME/.cargo/bin" >> $GITHUB_PATH

# Source for this step
source $HOME/.cargo/env

echo "Installing CMake 3.26.4..."
curl -L https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-aarch64.sh -o cmake.sh
chmod +x cmake.sh
./cmake.sh --skip-license --prefix=/usr/local
cmake --version

- name: Update apt repositories (Linux)
if: contains(matrix.os, 'ubuntu') && matrix.container_image == null
run: |
sudo apt-get update -y
sudo apt-get install -y build-essential

- name: Set up Rust
run: |
rustup override set stable
rustup update
rustup target add ${{ matrix.target }}
rustup component add rust-src

- name: Build binaries
run: |
# Ensure -p is used for the correct package
cargo build -p scouter-server \
--target ${{ matrix.target }} \
--features ${{ matrix.feature }}

- name: Prepare and Archive binary
id: prepare
shell: bash
run: |
# Create the unique base name including target, feature, and suffix
ARTIFACT_BASE_NAME="${{ env.BINARY_NAME }}-${{ matrix.target }}-${{ matrix.feature }}${{ matrix.archive_name_suffix }}"
ARTIFACT_ARCHIVE_NAME="${ARTIFACT_BASE_NAME}.${{ matrix.archive_ext }}"

mkdir -p release-bin
# Copy the binary from the target directory
cp target/${{ matrix.target }}/debug/${{ env.BINARY_NAME }} release-bin/
chmod +x release-bin/${{ env.BINARY_NAME }}

# Create archive
cd release-bin
# This command must be on its own line
tar -czf ../${ARTIFACT_ARCHIVE_NAME} ./*

# Now, echo the outputs to $GITHUB_OUTPUT on new lines
echo "ARTIFACT_BASE_NAME=${ARTIFACT_BASE_NAME}" >> $GITHUB_OUTPUT
echo "ARTIFACT_ARCHIVE_NAME=${ARTIFACT_ARCHIVE_NAME}" >> $GITHUB_OUTPUT

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare.outputs.ARTIFACT_BASE_NAME }}
path: ${{ steps.prepare.outputs.ARTIFACT_ARCHIVE_NAME }}
retention-days: 1

publish-docker-images-arm64:
needs: build
name: Publish ARM64 Docker images - ${{ matrix.image }} - ${{ matrix.feature }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- image: ubuntu
tag_suffix: ubuntu
artifact: scouter-server-aarch64-unknown-linux-gnu-kafka
feature: kafka

- image: rocky
tag_suffix: rocky-minimal
artifact: scouter-server-aarch64-unknown-linux-gnu-kafka-rocky
feature: kafka
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Download ARM64 Linux binary artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ./artifacts

- name: List downloaded files
run: ls -la ./artifacts

- name: Extract binary
run: |
archive="./artifacts/${{ matrix.artifact }}.tar.gz"
if [ -f "$archive" ]; then
mkdir -p binary
tar -xzf "$archive" -C ./binary
chmod +x ./binary/scouter-server
else
echo "ARM64 binary $archive not found, skipping this build"
exit 1
fi

- name: Set version tag
id: set-version
run: |
# Use a default version tag of 'dev' for PRs
echo "VERSION=dev" >> $GITHUB_OUTPUT

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push ARM64 image
uses: docker/build-push-action@v5
with:
context: .
file: docker/official/${{ matrix.image }}/Dockerfile
push: true
platforms: linux/arm64
build-args: |
SCOUTER_SERVER_BINARY=./binary/${{ env.BINARY_NAME }}
TINI_BIN=tini-arm64
tags: |
demml/scouter:${{ matrix.tag_suffix }}-arm64-${{ steps.set-version.outputs.VERSION }}-${{ matrix.feature }}
cache-from: type=gha
cache-to: type=gha,mode=max
Loading