Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Commit a772ec1

Browse files
committed
feat: Add minimal dibs config
1 parent d125b96 commit a772ec1

File tree

12 files changed

+390
-36
lines changed

12 files changed

+390
-36
lines changed

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# syntax=docker/dockerfile:experimental
2+
# Build container
3+
FROM --platform=$TARGETPLATFORM golang AS build
4+
ARG DIBS_TARGET
5+
ARG TARGETPLATFORM
6+
7+
WORKDIR /app
8+
9+
RUN apt update
10+
RUN apt install -y protobuf-compiler gcc make git file
11+
12+
RUN curl -Lo /tmp/dibs https://github.com/pojntfx/dibs/releases/latest/download/dibs-linux-amd64
13+
RUN install /tmp/dibs /usr/local/bin
14+
15+
ENV GO111MODULE=on
16+
17+
RUN go get github.com/golang/protobuf/protoc-gen-go
18+
RUN go get github.com/rakyll/statik
19+
20+
ADD . .
21+
22+
RUN dibs -generateSources
23+
RUN dibs -build
24+
25+
# Run container
26+
FROM --platform=$TARGETPLATFORM debian
27+
ARG DIBS_TARGET
28+
ARG TARGETPLATFORM
29+
30+
COPY --from=build /app/.bin/binaries/ipxebuilderd* /usr/local/bin/ipxebuilderd
31+
32+
CMD /usr/local/bin/ipxebuilderd

Dockerfile.chartTests

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# syntax=docker/dockerfile:experimental
2+
# Build container
3+
FROM --platform=$TARGETPLATFORM alpine AS build
4+
ARG DIBS_TARGET
5+
ARG TARGETPLATFORM
6+
7+
WORKDIR /app
8+
9+
RUN apk add -u curl tar
10+
11+
RUN curl -Lo /tmp/dibs https://github.com/pojntfx/dibs/releases/latest/download/dibs-linux-amd64
12+
RUN install /tmp/dibs /usr/local/bin
13+
14+
RUN curl -L https://get.helm.sh/helm-v3.1.1-linux-amd64.tar.gz | tar -zvxf - linux-amd64/helm -O >/tmp/helm
15+
RUN install /tmp/helm /usr/local/bin
16+
17+
ADD . .
18+
19+
RUN dibs -buildChart
20+
21+
# Run container
22+
FROM --platform=$TARGETPLATFORM docker:stable
23+
ARG DIBS_TARGET
24+
ARG TARGETPLATFORM
25+
26+
WORKDIR /app
27+
28+
RUN apk add -u curl tar
29+
30+
RUN curl -L https://get.helm.sh/helm-v3.1.1-linux-amd64.tar.gz | tar -zvxf - linux-amd64/helm -O >/tmp/helm
31+
RUN install /tmp/helm /usr/local/bin
32+
33+
RUN curl -Lo /tmp/dibs https://github.com/pojntfx/dibs/releases/latest/download/dibs-linux-amd64
34+
RUN install /tmp/dibs /usr/local/bin
35+
36+
RUN curl -Lo /tmp/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
37+
RUN install /tmp/kubectl /usr/local/bin
38+
39+
RUN curl -Lo /tmp/k3d https://github.com/rancher/k3d/releases/download/v1.3.4/k3d-linux-amd64
40+
RUN install /tmp/k3d /usr/local/bin
41+
42+
COPY --from=build /app /app
43+
44+
CMD k3d delete || true \
45+
&& k3d create \
46+
--server-arg "--tls-san=$(/sbin/ip route|awk '/default/ { print $3 }')" \
47+
--wait 10 \
48+
&& mkdir -p ~/.kube \
49+
&& cat $(k3d get-kubeconfig --name='k3s-default') | sed -e "s/127.0.0.1/$(/sbin/ip route|awk '/default/ { print $3 }')/g" > ~/.kube/config \
50+
&& dibs -chartTests \
51+
&& k3d delete

Dockerfile.dev

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# syntax=docker/dockerfile:experimental
2+
FROM --platform=$TARGETPLATFORM golang AS build
3+
ARG DIBS_TARGET
4+
ARG TARGETPLATFORM
5+
6+
WORKDIR /app
7+
8+
RUN apt update
9+
RUN apt install -y protobuf-compiler gcc make git file
10+
11+
RUN curl -Lo /tmp/dibs https://github.com/pojntfx/dibs/releases/latest/download/dibs-linux-amd64
12+
RUN install /tmp/dibs /usr/local/bin
13+
14+
ENV GO111MODULE=on
15+
16+
RUN go get github.com/golang/protobuf/protoc-gen-go
17+
RUN go get github.com/rakyll/statik
18+
RUN go get github.com/go-delve/delve/cmd/dlv
19+
20+
ADD . .
21+
22+
RUN dibs -generateSources
23+
# Tests are disabled because there currently are none.
24+
# To reduce build time, automatic sources generation has also been disabled. To generate sources manually, please re-deploy manually.
25+
CMD dibs -dev -skipGenerateSources -skipTests

Dockerfile.dhcpdctl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# syntax=docker/dockerfile:experimental
2+
# Build container
3+
FROM --platform=$TARGETPLATFORM golang AS build
4+
ARG DIBS_TARGET
5+
ARG TARGETPLATFORM
6+
7+
WORKDIR /app
8+
9+
RUN apt update
10+
RUN apt install -y protobuf-compiler gcc make git file
11+
12+
RUN curl -Lo /tmp/dibs https://github.com/pojntfx/dibs/releases/latest/download/dibs-linux-amd64
13+
RUN install /tmp/dibs /usr/local/bin
14+
15+
ENV GO111MODULE=on
16+
17+
RUN go get github.com/golang/protobuf/protoc-gen-go
18+
RUN go get github.com/rakyll/statik
19+
20+
ADD . .
21+
22+
RUN dibs -generateSources
23+
RUN dibs -build
24+
25+
# Run container
26+
FROM --platform=$TARGETPLATFORM debian
27+
ARG DIBS_TARGET
28+
ARG TARGETPLATFORM
29+
30+
COPY --from=build /app/.bin/binaries/dhcpdctl* /usr/local/bin/dhcpdctl
31+
32+
CMD /usr/local/bin/dhcpdctl

Dockerfile.integrationTests

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# syntax=docker/dockerfile:experimental
2+
# Build container
3+
FROM --platform=$TARGETPLATFORM golang AS build
4+
ARG DIBS_TARGET
5+
ARG TARGETPLATFORM
6+
7+
WORKDIR /app
8+
9+
RUN apt update
10+
RUN apt install -y protobuf-compiler gcc make git file
11+
12+
RUN curl -Lo /tmp/dibs https://github.com/pojntfx/dibs/releases/latest/download/dibs-linux-amd64
13+
RUN install /tmp/dibs /usr/local/bin
14+
15+
ENV GO111MODULE=on
16+
17+
RUN go get github.com/golang/protobuf/protoc-gen-go
18+
RUN go get github.com/rakyll/statik
19+
20+
ADD . .
21+
22+
RUN dibs -generateSources
23+
RUN dibs -build
24+
25+
# Run container
26+
FROM --platform=$TARGETPLATFORM golang
27+
ARG DIBS_TARGET
28+
ARG TARGETPLATFORM
29+
30+
WORKDIR /app
31+
32+
RUN curl -Lo /tmp/dibs https://github.com/pojntfx/dibs/releases/latest/download/dibs-linux-amd64
33+
RUN install /tmp/dibs /usr/local/bin
34+
35+
COPY --from=build /app /app
36+
37+
CMD dibs -integrationTests

Dockerfile.unitTests

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# syntax=docker/dockerfile:experimental
2+
FROM --platform=$TARGETPLATFORM golang AS build
3+
ARG DIBS_TARGET
4+
ARG TARGETPLATFORM
5+
6+
WORKDIR /app
7+
8+
RUN apt update
9+
RUN apt install -y protobuf-compiler gcc make git file
10+
11+
RUN curl -Lo /tmp/dibs https://github.com/pojntfx/dibs/releases/latest/download/dibs-linux-amd64
12+
RUN install /tmp/dibs /usr/local/bin
13+
14+
ENV GO111MODULE=on
15+
16+
RUN go get github.com/golang/protobuf/protoc-gen-go
17+
RUN go get github.com/rakyll/statik
18+
19+
ADD . .
20+
21+
RUN dibs -generateSources
22+
CMD dibs -unitTests

dibs.yaml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
targets:
2+
- name: linux
3+
helm:
4+
src: charts/dhcpdd
5+
dist: .bin/chart
6+
dockerManifest: pojntfx/dhcpdd:latest
7+
platforms:
8+
- identifier: linux/amd64
9+
paths:
10+
watch: .
11+
include: (.*)\.go
12+
assetInImage: /usr/local/bin/dhcpdd
13+
assetOut: .bin/binaries/dhcpdd-linux-amd64
14+
gitRepoRoot: .
15+
commands:
16+
generateSources: go generate ./...
17+
build: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags netgo -ldflags '-extldflags "-static"' -o .bin/binaries/dhcpdd-linux-amd64 cmd/dhcpdd/main.go
18+
unitTests: go test -v ./...
19+
integrationTests: .bin/binaries/dhcpdd-linux-amd64 --help
20+
imageTests: docker run --platform linux/amd64 -e DIBS_TARGET=linux -e TARGETPLATFORM=linux/amd64 pojntfx/dhcpdd:linux-amd64 /usr/local/bin/dhcpdd --help
21+
chartTests: helm install dhcpdd .bin/chart/dhcpdd-*.tgz && helm delete dhcpdd
22+
start: |
23+
if [ "$DIBS_DEBUG" = "true" ]; then
24+
pkill -9 dlv || true
25+
pkill -9 dhcpdd || true
26+
.bin/binaries/dhcpdd-linux-amd64 &
27+
dlv attach $! --headless --listen=:31441 --api-version=2 --accept-multiclient || true
28+
else
29+
.bin/binaries/dhcpdd-linux-amd64
30+
fi
31+
docker:
32+
build:
33+
file: Dockerfile
34+
context: .
35+
tag: pojntfx/dhcpdd:linux-amd64
36+
unitTests:
37+
file: Dockerfile.unitTests
38+
context: .
39+
tag: pojntfx/dhcpdd-unit-tests:linux-amd64
40+
integrationTests:
41+
file: Dockerfile.integrationTests
42+
context: .
43+
tag: pojntfx/dhcpdd-integration-tests:linux-amd64
44+
chartTests:
45+
file: Dockerfile.chartTests
46+
context: .
47+
tag: pojntfx/dhcpdd-chart-tests:linux-amd64
48+
- identifier: linux/arm64
49+
paths:
50+
watch: .
51+
include: (.*)\.go
52+
assetInImage: /usr/local/bin/dhcpdd
53+
assetOut: .bin/binaries/dhcpdd-linux-arm64
54+
gitRepoRoot: .
55+
commands:
56+
generateSources: go generate ./...
57+
build: GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags netgo -ldflags '-extldflags "-static"' -o .bin/binaries/dhcpdd-linux-arm64 cmd/dhcpdd/main.go
58+
unitTests: go test -v ./...
59+
integrationTests: .bin/binaries/dhcpdd-linux-arm64 --help
60+
imageTests: docker run --platform linux/arm64 -e DIBS_TARGET=linux -e TARGETPLATFORM=linux/arm64 pojntfx/dhcpdd:linux-arm64 /usr/local/bin/dhcpdd --help
61+
chartTests: helm install dhcpdd .bin/chart/dhcpdd-*.tgz && helm delete dhcpdd
62+
start: |
63+
if [ "$DIBS_DEBUG" = "true" ]; then
64+
pkill -9 dlv || true
65+
pkill -9 dhcpdd || true
66+
.bin/binaries/dhcpdd-linux-arm64 &
67+
dlv attach $! --headless --listen=:31441 --api-version=2 --accept-multiclient || true
68+
else
69+
.bin/binaries/dhcpdd-linux-arm64
70+
fi
71+
docker:
72+
build:
73+
file: Dockerfile
74+
context: .
75+
tag: pojntfx/dhcpdd:linux-arm64
76+
unitTests:
77+
file: Dockerfile.unitTests
78+
context: .
79+
tag: pojntfx/dhcpdd-unit-tests:linux-arm64
80+
integrationTests:
81+
file: Dockerfile.integrationTests
82+
context: .
83+
tag: pojntfx/dhcpdd-integration-tests:linux-arm64
84+
chartTests:
85+
file: Dockerfile.chartTests
86+
context: .
87+
tag: pojntfx/dhcpdd-chart-tests:linux-arm64
88+
- name: dhcpdctl-linux
89+
platforms:
90+
- identifier: linux/amd64
91+
paths:
92+
watch: .
93+
include: (.*)\.go
94+
assetInImage: /usr/local/bin/dhcpdctl
95+
assetOut: .bin/binaries/dhcpdctl-linux-amd64
96+
gitRepoRoot: .
97+
commands:
98+
generateSources: go generate ./...
99+
build: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags netgo -ldflags '-extldflags "-static"' -o .bin/binaries/dhcpdctl-linux-amd64 cmd/dhcpdctl/main.go
100+
unitTests: go test -v ./...
101+
integrationTests: .bin/binaries/dhcpdctl-linux-amd64 --help
102+
start: .bin/binaries/dhcpdctl-linux-amd64 --help
103+
docker:
104+
build:
105+
file: Dockerfile.dhcpdctl
106+
context: .
107+
tag: pojntfx/dhcpdctl:linux-amd64 # Only to get the binaries from Docker
108+
unitTests:
109+
file: Dockerfile.unitTests
110+
context: .
111+
tag: pojntfx/dhcpdctl-unit-tests:linux-amd64
112+
integrationTests:
113+
file: Dockerfile.integrationTests
114+
context: .
115+
tag: pojntfx/dhcpdctl-integration-tests:linux-amd64
116+
- identifier: linux/arm64
117+
paths:
118+
watch: .
119+
include: (.*)\.go
120+
assetInImage: /usr/local/bin/dhcpdctl
121+
assetOut: .bin/binaries/dhcpdctl-linux-arm64
122+
gitRepoRoot: .
123+
commands:
124+
generateSources: go generate ./...
125+
build: GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags netgo -ldflags '-extldflags "-static"' -o .bin/binaries/dhcpdctl-linux-arm64 cmd/dhcpdctl/main.go
126+
unitTests: go test -v ./...
127+
integrationTests: .bin/binaries/dhcpdctl-linux-arm64 --help
128+
start: .bin/binaries/dhcpdctl-linux-arm64 --help
129+
docker:
130+
build:
131+
file: Dockerfile.dhcpdctl
132+
context: .
133+
tag: pojntfx/dhcpdctl:linux-arm64 # Only to get the binaries from Docker
134+
unitTests:
135+
file: Dockerfile.unitTests
136+
context: .
137+
tag: pojntfx/dhcpdctl-unit-tests:linux-arm64
138+
integrationTests:
139+
file: Dockerfile.integrationTests
140+
context: .
141+
tag: pojntfx/dhcpdctl-integration-tests:linux-arm64
142+
- name: dhcpdctl-darwin
143+
platforms:
144+
- identifier: darwin/amd64
145+
paths:
146+
watch: .
147+
include: (.*)\.go
148+
gitRepoRoot: .
149+
commands:
150+
generateSources: go generate ./...
151+
build: GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -tags netgo -ldflags '-extldflags "-static"' -o .bin/binaries/dhcpdctl-darwin-amd64 cmd/dhcpdctl/main.go
152+
unitTests: go test -v ./...
153+
integrationTests: .bin/binaries/dhcpdctl-darwin-amd64 --help
154+
start: .bin/binaries/dhcpdctl-darwin-amd64 --help

go.mod

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
module github.com/pojntfx/go-isc-dhcp
22

3-
go 1.13
3+
go 1.14
44

55
require (
66
github.com/fatih/color v1.9.0 // indirect
77
github.com/ghodss/yaml v1.0.0
8-
github.com/golang/protobuf v1.3.2
98
github.com/gosuri/uitable v0.0.4
10-
github.com/mattn/go-runewidth v0.0.7 // indirect
11-
github.com/rakyll/statik v0.1.6
9+
github.com/mattn/go-runewidth v0.0.8 // indirect
10+
github.com/rakyll/statik v0.1.7
1211
github.com/satori/go.uuid v1.2.0
13-
github.com/spf13/cobra v0.0.5
14-
github.com/spf13/viper v1.6.1
12+
github.com/spf13/cobra v0.0.6
13+
github.com/spf13/viper v1.6.2
1514
gitlab.com/bloom42/libs/rz-go v1.3.0
16-
google.golang.org/grpc v1.26.0
15+
google.golang.org/grpc v1.27.1
1716
)

0 commit comments

Comments
 (0)