Skip to content

Commit a8194df

Browse files
committed
update: add Docker build and push workflow with multi-stage build support
1 parent ffcf546 commit a8194df

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

.github/workflows/build.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,34 @@ env:
1010
permissions: write-all
1111

1212
jobs:
13+
docker:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Login to Docker Hub
17+
uses: docker/login-action@v3
18+
with:
19+
username: k8spider
20+
password: ${{ secrets.DOCKERHUB_TOKEN }}
21+
- name: Set up QEMU
22+
uses: docker/setup-qemu-action@v3
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
- name: Extract metadata for the Docker image
26+
id: meta
27+
uses: docker/metadata-action@v5
28+
with:
29+
images: k8spider/k8spider
30+
tags: |
31+
type=semver,pattern={{version}}
32+
type=semver,pattern={{major}}.{{minor}}
33+
type=raw,value=latest
34+
type=sha
35+
- name: Build and push
36+
uses: docker/build-push-action@v6
37+
with:
38+
push: true
39+
tags: ${{ steps.meta.outputs.tags }}
40+
1341
goreleaser:
1442
runs-on: ubuntu-latest
1543
steps:

Dockerfile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM golang:1.21 AS builder
2+
WORKDIR /app
3+
COPY go.mod go.sum ./
4+
RUN go mod download
5+
COPY . .
6+
RUN CGO_ENABLE=0 go build -ldflags="-s -w" -tags netgo -o k8spider main.go
7+
8+
RUN ./k8spider all --help && \
9+
./k8spider axfr --help && \
10+
./k8spider dns --help && \
11+
./k8spider dnssd --help && \
12+
./k8spider dnssd ptr --help && \
13+
./k8spider dnssd srv --help && \
14+
./k8spider metrics --help && \
15+
./k8spider neighbor --help && \
16+
./k8spider neighbor pod --help && \
17+
./k8spider neighbor svc --help && \
18+
./k8spider whereisdns --help && \
19+
./k8spider wild --help && \
20+
echo "all command flag is successfully processed with no conflict"
21+
22+
FROM alpine:latest
23+
LABEL maintainer="Esonhugh"
24+
LABEL name="k8spider"
25+
LABEL url="https://github.com/esonhugh/k8spider"
26+
LABEL description="A Powerful+Fast+Low Privilege Kubernetes discovery tools"
27+
COPY --from=builder /app/k8spider /k8spider
28+
ENTRYPOINT ["/k8spider"]
29+
CMD ["all"]

go.mod

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ module github.com/esonhugh/k8spider
22

33
go 1.21.0
44

5-
toolchain go1.23.2
6-
75
require (
86
github.com/elastic/go-grok v0.3.1
97
github.com/miekg/dns v1.1.58

0 commit comments

Comments
 (0)