Files
spore-registry/Makefile
2025-10-27 21:37:53 +01:00

69 lines
1.4 KiB
Makefile

.PHONY: build run test clean docker-build docker-run docker-push docker-build-multiarch docker-push-multiarch
# Build the application
build:
go build -o spore-registry main.go
# Run the application
run:
go run main.go
# Run tests
test:
go test -v ./...
# Clean build artifacts
clean:
rm -f spore-registry
rm -rf registry/
# Run tests with coverage
test-coverage:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# Format code
fmt:
go fmt ./...
# Lint code (requires golangci-lint)
lint:
golangci-lint run
# Install dependencies
deps:
go mod download
go mod tidy
# Docker variables
DOCKER_REGISTRY ?=
IMAGE_NAME = wirelos/spore-registry
IMAGE_TAG ?= latest
FULL_IMAGE_NAME = $(if $(DOCKER_REGISTRY),$(DOCKER_REGISTRY)/$(IMAGE_NAME),$(IMAGE_NAME)):$(IMAGE_TAG)
# Build Docker image
docker-build:
docker build -t $(FULL_IMAGE_NAME) .
# Run Docker container
docker-run:
docker run -p 8080:8080 -v registry-data:/data/registry --rm $(FULL_IMAGE_NAME)
# Push Docker image
docker-push:
docker push $(FULL_IMAGE_NAME)
# Build multiarch Docker image
docker-build-multiarch:
docker buildx build --platform linux/amd64,linux/arm64 \
-t $(FULL_IMAGE_NAME) \
--push \
.
# Push multiarch Docker image (if not pushed during build)
docker-push-multiarch:
docker buildx build --platform linux/amd64,linux/arm64 \
-t $(FULL_IMAGE_NAME) \
--push \
.