Skip to content

Commit

Permalink
Bun Makeover (#48)
Browse files Browse the repository at this point in the history
* bun it up!

* docker files

* Update README.md

* use Bun

* Update docker-build.yml

* Delete .github/workflows/docker-publish.yml

* Update docker-build.yml
  • Loading branch information
lmangani authored Jan 26, 2025
1 parent 851c19b commit 8f1d8a6
Show file tree
Hide file tree
Showing 43 changed files with 539 additions and 4,812 deletions.
25 changes: 6 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# This workflow will do:
# a clean install of node dependencies,
# build the source code,
# and run tests across different versions of node

name: Node.js CI
name: Bun.sh CI

on:
push:
Expand All @@ -16,17 +11,9 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
# Currently there are no tests to run
# - run: npm test
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun build ./hepop.js --compile --outfile hepop

71 changes: 38 additions & 33 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,47 @@
name: Docker Build CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [published]

jobs:
build:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest

permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
# required pre-steps for docker + cache
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: sipcapture/hepop

# establish the docker tag to use
- name: Prepare
id: prep
run: |
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g')
TAG="$(echo -e "${PACKAGE_VERSION}-$(date +%s)" | tr -d '[:space:]')"
echo ::set-output name=version::${TAG}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build wihtout push
uses: docker/build-push-action@v2
with:
file: ./docker/Dockerfile
tags: sipcapture/hepop:${{ steps.prep.outputs.version }}
push: false
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
50 changes: 0 additions & 50 deletions .github/workflows/docker-publish.yml

This file was deleted.

117 changes: 0 additions & 117 deletions DEVTUTORIAL.md

This file was deleted.

13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM oven/bun:1 AS build
WORKDIR /app
COPY . .
RUN bun install
RUN bun build ./hepop.js --compile --outfile /app/hepop
RUN chmod +x /app/hepop

FROM gcr.io/distroless/cc
WORKDIR /app
COPY --from=build /app/hepop /app/hepop
EXPOSE 9069/udp
EXPOSE 9069/tcp
CMD [ "./hepop" ]
Loading

0 comments on commit 8f1d8a6

Please sign in to comment.