add: build artifacts
This commit is contained in:
89
Makefile
Normal file
89
Makefile
Normal file
@@ -0,0 +1,89 @@
|
||||
# Makefile for mcgod project
|
||||
|
||||
# Variables
|
||||
BINARY_NAME = mcgod
|
||||
DOCKER_IMAGE = docker.tipsy.codes/mcgod:latest
|
||||
DOCKER_PLATFORMS = linux/amd64,linux/arm64
|
||||
|
||||
# Default target
|
||||
.PHONY: build
|
||||
build: build-amd64
|
||||
|
||||
# Build for AMD64
|
||||
.PHONY: build-amd64
|
||||
build-amd64:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o ${BINARY_NAME} ./cmd/mcgod
|
||||
|
||||
# Build for ARM64
|
||||
.PHONY: build-arm64
|
||||
build-arm64:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -installsuffix cgo -o ${BINARY_NAME} ./cmd/mcgod
|
||||
|
||||
# Build multi-architecture Docker image
|
||||
.PHONY: build-docker
|
||||
build-docker:
|
||||
docker buildx build --platform ${DOCKER_PLATFORMS} -t ${DOCKER_IMAGE} --push .
|
||||
|
||||
# Build Docker image for current architecture
|
||||
.PHONY: build-docker-local
|
||||
build-docker-local:
|
||||
docker build -t ${DOCKER_IMAGE} .
|
||||
|
||||
# Clean build artifacts
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f ${BINARY_NAME}
|
||||
rm -f ${BINARY_NAME}.tar.gz
|
||||
|
||||
# Run the application locally
|
||||
.PHONY: run
|
||||
run:
|
||||
./${BINARY_NAME}
|
||||
|
||||
# Run with Docker
|
||||
.PHONY: run-docker
|
||||
run-docker:
|
||||
docker run --rm -it ${DOCKER_IMAGE}
|
||||
|
||||
# Format Go code
|
||||
.PHONY: fmt
|
||||
fmt:
|
||||
go fmt ./...
|
||||
|
||||
# Lint Go code
|
||||
.PHONY: lint
|
||||
lint:
|
||||
golangci-lint run
|
||||
|
||||
# Test the application
|
||||
.PHONY: test
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
# All targets
|
||||
.PHONY: all
|
||||
all: build clean
|
||||
|
||||
# Generate Go documentation
|
||||
.PHONY: doc
|
||||
doc:
|
||||
go doc ./...
|
||||
|
||||
# Check dependencies
|
||||
.PHONY: deps
|
||||
deps:
|
||||
go list -m all
|
||||
|
||||
# Update dependencies
|
||||
.PHONY: update
|
||||
update:
|
||||
go get -u ./...
|
||||
|
||||
# Run vet
|
||||
.PHONY: vet
|
||||
vet:
|
||||
go vet ./...
|
||||
|
||||
# Run all checks
|
||||
.PHONY: check
|
||||
check: fmt vet lint test
|
||||
Reference in New Issue
Block a user