Skip to content

Commit

Permalink
Initial toolbox image impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Frostman committed Nov 30, 2023
1 parent 592e0b1 commit 1e1652a
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CI

concurrency:
group: ci-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
push:
branches:
- master
pull_request:
schedule:
- cron: "0 10 * * *" # ~2am PST
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: false

env:
REGISTRY: ghcr.io
ORG: githedgehog

jobs:
dockers:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

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

- name: Set up Docker Context for Buildx
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
endpoint: builders

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.ORG }}/toolbox
tags: |
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push (on master only) Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Setup tmate session for debug
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 30
with:
limit-access-to-actor: true

dockers-results:
name: Docker Build/Publish Results
needs:
- dockers
if: ${{ always() }}

runs-on: ubuntu-latest

steps:
- run: |
result="${{ needs.dockers.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM ubuntu:jammy

RUN --mount=type=bind,source=packages.sh,target=/tmp/packages.sh /tmp/packages.sh
25 changes: 25 additions & 0 deletions packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -eux
set -o pipefail

APT_PACKAGES=(
curl
dhcping
ethtool
iperf3
iproute2
iputils-ping
net-tools
openssh-client
socat
tcpdump
wget
)

apt-get update -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes \
"${APT_PACKAGES[@]}" \
&& apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/apt/lists/*

0 comments on commit 1e1652a

Please sign in to comment.