Skip to content

Commit 348dd72

Browse files
committed
Merge branch 'master' into rebuild-scripts
2 parents 6ecc5e2 + 828ccfe commit 348dd72

20 files changed

Lines changed: 832 additions & 236 deletions

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
2+
# Ignore all files which are not go type or shell scripts
3+
!**/*.go
4+
!**/*.mod
5+
!**/*.sum
6+
!**/*.sh

Dockerfile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18-
FROM golang:1.22 AS builder
18+
FROM golang:1.23 AS builder
1919

2020
WORKDIR /workspace
2121

22-
# Copy the Go Modules manifests
23-
COPY go.mod go.mod
24-
COPY go.sum go.sum
25-
26-
# Copy the Go source tree
27-
COPY cmd/ cmd/
28-
COPY internal/ internal/
29-
COPY pkg/ pkg/
22+
# Copy all source files, avoid producing multiple layers
23+
# See .dockerignore for exclusions
24+
COPY . .
3025

3126
# Build
3227
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o nnf-ec ./cmd/nnf_ec.go

Makefile

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,62 +21,105 @@ PROD_VERSION=$(shell sed 1q .version)
2121
DEV_IMGNAME=nnf-ec
2222
DTR_IMGPATH=ghcr.io/nearnodeflash/$(DEV_IMGNAME)
2323

24-
all: image
25-
26-
vendor:
24+
.DEFAULT_GOAL := help
25+
26+
## Display this help message
27+
help:
28+
@echo "NNF Element Controller (nnf-ec) Makefile"
29+
@echo ""
30+
@echo "Available targets:"
31+
@echo ""
32+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
33+
@echo ""
34+
@echo "Docker cleanup targets:"
35+
@echo " clean-images Remove all project-related Docker images"
36+
@echo " clean-docker-all Remove ALL unused Docker resources (aggressive)"
37+
@echo " clean-docker-images Remove unused Docker images only"
38+
@echo " clean-docker-cache Remove Docker build cache"
39+
@echo " clean-project-docker Remove project Docker images and unused resources"
40+
@echo ""
41+
42+
all: image ## Build the default Docker image
43+
44+
vendor: ## Download Go module dependencies
2745
go mod vendor
2846

29-
vet:
47+
vet: ## Run Go vet on all packages
3048
go vet `go list -f {{.Dir}} ./...`
3149

32-
fmt:
50+
fmt: ## Format Go source code
3351
go fmt `go list -f {{.Dir}} ./...`
3452

35-
generate:
53+
generate: ## Generate code and redfish/swordfish message registries
3654
( cd ./pkg/manager-message-registry/generator && go build msgenerator.go )
3755
go generate ./...
3856
go fmt ./pkg/manager-message-registry/registries
3957

40-
test:
58+
test: ## Run Go unit tests locally
4159
go test -v ./...
4260

43-
linux:
61+
linux: ## Build Linux binary
4462
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${DEV_IMGNAME} ./cmd/nnf_ec.go
4563

46-
image:
64+
image: ## Build Docker image
4765
docker build --file Dockerfile --label $(DTR_IMGPATH):$(PROD_VERSION) --tag $(DTR_IMGPATH):$(PROD_VERSION) .
4866

49-
container-unit-test:
67+
container-unit-test: ## Run containerized unit tests
5068
docker build -f Dockerfile --label $(DTR_IMGPATH)-$@:$(PROD_VERSION)-$@ -t $(DTR_IMGPATH)-$@:$(PROD_VERSION) --target $@ .
5169
docker run --rm -t --name $@ -v $(PWD):$(PWD):rw,z $(DTR_IMGPATH)-$@:$(PROD_VERSION)
5270

5371
# This and the corresponding clean-lint should go away and move to git pre-commit hook
54-
lint:
72+
lint: ## Run linting checks in Docker container
5573
docker build -f Dockerfile --label $(DTR_IMGPATH)-$@:$(PROD_VERSION)-$@ -t $(DTR_IMGPATH)-$@:$(PROD_VERSION) --target $@ .
5674
docker run --rm -t --name $@ -v $(PWD):$(PWD):rw,z $(DTR_IMGPATH)-$@:$(PROD_VERSION)
5775

5876
# This and the cooresponding clean-codestyle should go away and move to git pre-commit hook
59-
codestyle:
77+
codestyle: ## Run code style checks in Docker container
6078
docker build -f Dockerfile --label $(DTR_IMGPATH)-$@:$(PROD_VERSION) -t $(DTR_IMGPATH)-$@:$(PROD_VERSION) --target $@ .
6179
docker run --rm -t --name $@ -v $(PWD):$(PWD):rw,z $(DTR_IMGPATH)-$@:$(PROD_VERSION)
6280

63-
clean-lint:
81+
clean-lint: ## Clean lint Docker images and containers
6482
docker rmi $(DTR_IMGPATH)-lint:$(PROD_VERSION) || true
83+
docker container rm lint || true
6584

66-
clean-codestyle:
85+
clean-codestyle: ## Clean codestyle Docker images and containers
6786
docker rmi $(DTR_IMGPATH)-codestyle:$(PROD_VERSION) || true
87+
docker container rm codestyle || true
88+
89+
clean-container-unit-test: ## Clean container-unit-test Docker images and containers
90+
docker rmi $(DTR_IMGPATH)-container-unit-test:$(PROD_VERSION) || true
91+
docker container rm container-unit-test || true
6892

6993
# push:
7094
# docker push $(DTR_IMGPATH):$(PROD_VERSION)
7195

72-
kind-push: image
96+
kind-push: image ## Load Docker image into kind cluster
7397
kind load docker-image $(DTR_IMGPATH):$(PROD_VERSION)
7498

75-
clean: clean-db
99+
clean: clean-db ## Clean build artifacts and Docker resources
76100
docker container prune --force
77101
docker image prune --force
78-
docker rmi $(DTR_IMGPATH):$(PROD_VERSION)
102+
docker rmi $(DTR_IMGPATH):$(PROD_VERSION) || true
79103
go clean all
80104

81-
clean-db:
105+
clean-images: ## Clean all Docker images related to this project
106+
docker rmi $(DTR_IMGPATH):$(PROD_VERSION) || true
107+
docker rmi $(DTR_IMGPATH)-container-unit-test:$(PROD_VERSION) || true
108+
docker rmi $(DTR_IMGPATH)-lint:$(PROD_VERSION) || true
109+
docker rmi $(DTR_IMGPATH)-codestyle:$(PROD_VERSION) || true
110+
111+
clean-docker-all: ## Remove ALL unused Docker resources (aggressive)
112+
docker system prune -a --volumes --force
113+
114+
clean-docker-images: ## Remove unused Docker images only
115+
docker image prune --force
116+
117+
clean-docker-cache: ## Remove Docker build cache
118+
docker builder prune --force
119+
120+
clean-project-docker: clean-images ## Remove project Docker images and unused resources
121+
docker container prune --force
122+
docker image prune --force
123+
124+
clean-db: ## Remove all database files
82125
find . -name "*.db" -type d -exec rm -rf {} +

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/NearNodeFlash/nnf-ec
22

3-
go 1.22.0
4-
5-
toolchain go1.22.5
3+
go 1.23.9
64

75
require (
86
github.com/HewlettPackard/structex v1.0.4

kubernetes/nnf-ec/Chart.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.
-11.3 KB
Binary file not shown.

kubernetes/nnf-ec/templates/NOTES.txt

Whitespace-only changes.

kubernetes/nnf-ec/templates/_helpers.tpl

Lines changed: 0 additions & 45 deletions
This file was deleted.

kubernetes/nnf-ec/templates/role.yaml

Lines changed: 0 additions & 32 deletions
This file was deleted.

kubernetes/nnf-ec/templates/role_binding.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)