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
83 changes: 83 additions & 0 deletions .github/workflows/nettools-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build and Push Network Tools Images

on:
push:
branches:
- master
- main
paths:
- 'docker/alpine-nettools.Dockerfile'
- 'docker/debian-nettools.Dockerfile'
- '.github/workflows/nettools-images.yaml'
pull_request:
paths:
- 'docker/alpine-nettools.Dockerfile'
- 'docker/debian-nettools.Dockerfile'
- '.github/workflows/nettools-images.yaml'
workflow_dispatch:

jobs:
build-and-push:
name: Build and Push Multi-Arch Images
runs-on: ubuntu-latest
strategy:
matrix:
image:
- name: alpine-nettools
file: docker/alpine-nettools.Dockerfile
base: alpine
- name: debian-nettools
file: docker/debian-nettools.Dockerfile
base: debian
permissions:
contents: read
packages: write

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
platforms: linux/amd64,linux/arm64

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/pumba-${{ matrix.image.name }}
tags: |
type=semver,pattern={{version}}
type=raw,value=latest
type=raw,value=${{ matrix.image.base }}
type=sha,format=short

- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.image.file }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: true
sbom: true
56 changes: 54 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,17 @@ test-coverage: setup-go-junit-report setup-gocov setup-gocov-xml; $(info $(M) ru
$Q $(GO) tool cover -func="$(COVERAGE_PROFILE)"
$Q $(GOCOV) convert $(COVERAGE_PROFILE) | $(GOCOVXML) > $(COVERAGE_XML)

# urun integration tests
# run integration tests
.PHONY: integration-tests
integration-tests: build ; $(info $(M) running integration tests with bats...) @ ## Run bats tests
$Q PATH=$(BIN)/$(dir $(MODULE)):$(PATH) pumba --version
$Q PATH=$(BIN)/$(dir $(MODULE)):$(PATH) $(BATS) tests
$Q PATH=$(BIN)/$(dir $(MODULE)):$(PATH) $(SHELL) tests/run_tests.sh

# run all integration tests including stress tests
.PHONY: integration-tests-all
integration-tests-all: build ; $(info $(M) running all integration tests with bats...) @ ## Run all bats tests including stress tests
$Q PATH=$(BIN)/$(dir $(MODULE)):$(PATH) pumba --version
$Q PATH=$(BIN)/$(dir $(MODULE)):$(PATH) $(SHELL) tests/run_tests.sh --all

.PHONY: lint
lint: setup-lint; $(info $(M) running golangci-lint...) @ ## Run golangci-lint
Expand Down Expand Up @@ -157,6 +163,52 @@ debug:
@echo $(BIN)/$(basename $(MODULE))
@echo $(TARGETOS)/$(TARGETARCH)

# NetTools Docker images
NETTOOLS_REPO := ghcr.io/alexei-led/pumba
NETTOOLS_PLATFORMS := linux/amd64,linux/arm64

.PHONY: build-nettools-images
build-nettools-images: ; $(info $(M) building multi-arch nettools images...) @ ## Build multi-arch nettools images
$Q $(DOCKER) buildx create --use --name nettools-builder --driver docker-container --bootstrap || true
$Q $(DOCKER) buildx build --platform $(NETTOOLS_PLATFORMS) \
-t $(NETTOOLS_REPO)/pumba-alpine-nettools:latest \
-f $(CURDIR)/docker/alpine-nettools.Dockerfile \
$(CURDIR)
$Q $(DOCKER) buildx build --platform $(NETTOOLS_PLATFORMS) \
-t $(NETTOOLS_REPO)/pumba-debian-nettools:latest \
-f $(CURDIR)/docker/debian-nettools.Dockerfile \
$(CURDIR)
$Q $(DOCKER) buildx rm nettools-builder

.PHONY: build-local-nettools
build-local-nettools: ; $(info $(M) building local nettools images for local architecture...) @ ## Build local nettools images
$Q $(DOCKER) build \
-t pumba-alpine-nettools:local \
-f $(CURDIR)/docker/alpine-nettools.Dockerfile \
$(CURDIR)
$Q $(DOCKER) build \
-t pumba-debian-nettools:local \
-f $(CURDIR)/docker/debian-nettools.Dockerfile \
$(CURDIR)

.PHONY: push-nettools-images
push-nettools-images: ; $(info $(M) building and pushing multi-arch nettools images...) @ ## Build and push multi-arch nettools images
@echo "Using repository: $(NETTOOLS_REPO)"
@echo "Checking if already logged in to ghcr.io..."
@$(DOCKER) buildx ls >/dev/null
$Q $(DOCKER) buildx create --use --name nettools-builder --driver docker-container --bootstrap || true
$Q $(DOCKER) buildx build --platform $(NETTOOLS_PLATFORMS) \
-t $(NETTOOLS_REPO)/pumba-alpine-nettools:latest \
--push \
-f $(CURDIR)/docker/alpine-nettools.Dockerfile \
$(CURDIR)
$Q $(DOCKER) buildx build --platform $(NETTOOLS_PLATFORMS) \
-t $(NETTOOLS_REPO)/pumba-debian-nettools:latest \
--push \
-f $(CURDIR)/docker/debian-nettools.Dockerfile \
$(CURDIR)
$Q $(DOCKER) buildx rm nettools-builder

# helper function: find module path
define source_of
$(shell go mod download -json | jq -r 'select(.Path == "$(1)").Dir' | tr '\\' '/' 2> /dev/null)
Expand Down
Loading
Loading