Skip to content

Commit

Permalink
add dockerfile Makefile and publish ci (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocfox authored Mar 21, 2023
1 parent 7184caa commit 875f76a
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 68 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build and publish

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')"
strategy:
matrix:
target: [ x86_64-unknown-linux-gnu ]

steps:
- uses: actions/checkout@v3

- name: Set latest release version
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
id: set_version
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const { data: tags } = await github.rest.repos.listTags({
owner: context.repo.owner,
repo: context.repo.repo
});
if (releases.length === 0) { return "v0.0.1"; }
function increase_v(version) {
const parts = version.split(".");
const last = parseInt(parts[2]) + 1;
const next_version = `${parts[0]}.${parts[1]}.${last.toString()}`;
return next_version;
}
const latest_release_tag = releases[0].tag_name;
const tag = tags.find(tag => tag.commit.sha === context.sha);
return tag ? tag.name : increase_v(latest_release_tag)
- name: install deps
run: |
sudo apt update
sudo apt-get install -y --no-install-recommends \
libcurl4-openssl-dev libelf-dev clang llvm cmake zlib1g-dev
wget https://github.com/eunomia-bpf/eunomia-bpf/releases/latest/download/ecc && chmod +x ./ecc
- name: build package
run: ./ecc template.bpf.c template.h

- name: Publish
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v1
with:
files: package.json
prerelease: false
tag_name: ${{ steps.set_version.outputs.result }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 0 additions & 49 deletions .github/workflows/ubuntu.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.vscode
package.json
*.o
*.skel.json
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build:
ecc template.bpf.c template.h

clean:
rm *.json
rm *.o
36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
---
layout: post
title: template
date: 2022-10-10 16:18
category: examples
author: yunwei37
tags: [bpftools, examples, tracepoint, ringbuf]
summary: A template for eunomia-bpf programs
---
# A template for eunomia-bpf programs

This is a template for eunomia-bpf eBPF programs.
You can use it as a template, compile it online with `Github Actions` or offline as a bootstrap template.

# A template for eunomia-bpf programs
### Use docker installed ecc and ecli

This is a template for eunomia-bpf eBPF programs. You can use t as a template, compile it online with `Github Actions` or offline as a bootstrap template.
Run the following code to access an environment with ecli and ecc,
where you can easily compile and run or debug ebpf programs in this docker.

### Compile and run the eBPF code as simple as possible!
```sh
docker build -t eunomia-template .
docker run -it eunomia-template:latest
```

Download the pre-compiled `ecli` binary from here: [eunomia-bpf/eunomia-bpf](https://github.com/eunomia-bpf/eunomia-bpf/releases)
### Compile and run the eBPF code as simple as possible!

To install, just download and use the `ecli` binary from here: [eunomia-bpf/eunomia-bpf](https://github.com/eunomia-bpf/eunomia-bpf/releases):
Download the pre-compiled `ecli` binary from here:
[eunomia-bpf/eunomia-bpf](https://github.com/eunomia-bpf/eunomia-bpf/releases)

```console
wget https://aka.pw/bpf-ecli -O ecli && chmod +x ecli
```
To install, just download and use the `ecli` binary from here:
[eunomia-bpf/eunomia-bpf](https://github.com/eunomia-bpf/eunomia-bpf/releases):

## use this repo as a github action to compile online

1. use this repo as a github template: see [creating-a-repository-from-a-template](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template)
2. modify the `bootstrap.bpf.c`, commit it and wait for the workflow to stop
2. modify the `template.bpf.c`, commit it and wait for the workflow to stop
3. Run the `ecli` with remote url:

```console
$ sudo ./ecli run https://eunomia-bpf.github.io/ebpm-template/package.json
$ sudo ./ecli run https://eunomia-bpf.github.io/eunomia-template/package.json
```

## quick start
Expand Down
12 changes: 12 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ghcr.io/eunomia-bpf/ecc-x86_64:latest

COPY . /root/template
WORKDIR /root/template

RUN wget -q -O /root/.eunomia/bin/ecli https://github.com/eunomia-bpf/eunomia-bpf/releases/latest/download/ecli

RUN chmod +x /root/.eunomia/bin/ecli

ENV PATH="/root/.eunomia/bin:${PATH}"

ENTRYPOINT ["/bin/bash"]

0 comments on commit 875f76a

Please sign in to comment.