Skip to content
Snippets Groups Projects
Commit 1b7699e1 authored by Mario Macias's avatar Mario Macias
Browse files

initial version of the build scripts

parent 1b0a7c97
No related branches found
No related tags found
No related merge requests found
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
bin/
linters:
enable:
- deadcode
- errcheck
- errorlint
- cyclop
- errname
- exhaustive
- exportloopref
- gocritic
- goimports
- gosimple
- govet
- ineffassign
- revive
- staticcheck
- structcheck
- stylecheck
- typecheck
- unused
- varcheck
linters-settings:
stylecheck:
go: "1.17"
gocritic:
enabled-checks:
- hugeParam
- rangeExprCopy
- rangeValCopy
- indexAlloc
- deprecatedComment
cyclop:
max-complexity: 20
# Build the manager binary
FROM registry.access.redhat.com/ubi8/go-toolset:1.16.7-5 as builder
ARG VERSION="unknown"
WORKDIR /opt/app-root
# TEMPORARY STEPS UNTIL ubi8 releases a go1.17 image
RUN wget -q https://go.dev/dl/go1.17.8.linux-amd64.tar.gz && tar -xzf go1.17.8.linux-amd64.tar.gz
ENV GOROOT /opt/app-root/go
ENV PATH $GOROOT/bin:$PATH
# END OF LINES TO REMOVE
# Copy the go manifests and source
COPY go.mod go.mod
COPY go.sum go.sum
COPY vendor/ vendor/
COPY main.go main.go
COPY cmd/ cmd/
COPY pkg/ pkg/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags "-X main.version=$OPVERSION" -mod vendor -a -o manager main.go
# Create final image from minimal + built binary
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5-204
WORKDIR /
COPY --from=builder /opt/app-root/netobserv-agent .
USER 65532:65532
ENTRYPOINT ["/netobserv-agent"]
Makefile 0 → 100644
# VERSION defines the project version for the bundle.
# Update this value when you upgrade the version of your project.
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= main
# IMAGE_TAG_BASE defines the namespace and part of the image name for remote images.
# This variable is used to construct full image tags for bundle and catalog images.
IMAGE_TAG_BASE ?= quay.io/netobserv/netobserv-agent
# Image URL to use all building/pushing image targets
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
GOLANGCI_LINT_VERSION = v1.42.1
# Image building tool (docker / podman)
ifeq (,$(shell which podman 2>/dev/null))
OCI_BIN=docker
else
OCI_BIN=podman
endif
.PHONY: vendors
vendors:
@echo "### Checking vendors"
go mod tidy && go mod vendor
.PHONY: prereqs
prereqs:
@echo "### Check if prerequisites are met, and installing missing dependencies"
test -f $(go env GOPATH)/bin/golangci-lint || GOFLAGS="" go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
.PHONY: fmt
fmt: ## Run go fmt against code.
@echo "### Formatting code"
go fmt ./...
.PHONY: lint
lint: prereqs
@echo "### Linting code"
golangci-lint run ./...
.PHONY: build
build: fmt vendors lint
@echo "### Building project"
go build -ldflags "-X main.version=${VERSION}" -mod vendor -o bin/netobserv-agent cmd/netobserv-agent.go
.PHONY: test
test:
@echo "### Testing code"
go test ./... -coverpkg=./... -coverprofile cover.out
.PHONY: coverage-report
coverage-report:
@echo "### Generating coverage report"
go tool cover --func=./cover.out
.PHONY: coverage-report-html
coverage-report-html:
@echo "### Generating HTML coverage report"
go tool cover --html=./cover.out
image-build: test ## Build OCI image with the manager.
$(OCI_BIN) build --build-arg VERSION="$(VERSION)" -t ${IMG} .
image-push: ## Push OCI image with the manager.
$(OCI_BIN) push ${IMG}
\ No newline at end of file
# netobserv-agent
# Network Observability Agent
Network Observability Agent
package main
import "fmt"
func main() {
fmt.Printf("hello")
}
go.mod 0 → 100644
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment