- build: add makefile, dockerfile, ci and development stack - feat(config): add environment configuration and logger - feat(server): add server lifecycle with health and version routes - feat(db): add connection, contract check, migrations and stores - feat(cli): add command dispatch and user management - test(db): add integration tests against mysql
80 lines
2.1 KiB
Makefile
80 lines
2.1 KiB
Makefile
#!make
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
# Copyright (C) 2026 Bryan Joshua Pedini
|
|
|
|
include .vars
|
|
|
|
APP_VERSION ?= latest
|
|
export APP_VERSION
|
|
COMMIT_ID := $(shell git rev-parse --verify --quiet --short=12 HEAD 2>/dev/null || echo undefined)
|
|
export COMMIT_ID
|
|
IMAGE = $${CONTAINER_ORG}/$${CONTAINER_IMAGE}:$${APP_VERSION}
|
|
GO_RUN = docker run --rm --user $$(id -u):$$(id -g) --env HOME=/tmp --env GOFLAGS=-buildvcs=false \
|
|
--volume $(CURDIR):/src --workdir /src $${GO_BUILDER}:$${GO_VERSION}
|
|
BINARY = coredns-web-ui
|
|
|
|
.PHONY: default clean build docker dockerpush test test-race lint integration test-e2e test-image run dockerrun version deploy
|
|
|
|
default: version
|
|
|
|
.vars:
|
|
cp vars.example .vars
|
|
|
|
clean:
|
|
rm -f ./$(BINARY)
|
|
if [ -n "$$(docker images --quiet "$${CONTAINER_ORG}/$${CONTAINER_IMAGE}")" ]; then \
|
|
docker image rm --force $$(docker images --format "{{.Repository}}:{{.Tag}}" "$${CONTAINER_ORG}/$${CONTAINER_IMAGE}"); \
|
|
fi
|
|
|
|
build:
|
|
$(GO_RUN) env CGO_ENABLED=0 GOOS=$${GO_OS} GOARCH=$${GO_ARCH} go build -trimpath \
|
|
-ldflags="-w -s -X 'main.APP_VERSION=$${APP_VERSION}' -X 'main.COMMIT_ID=$${COMMIT_ID}'" \
|
|
-o ./$(BINARY) .
|
|
|
|
docker:
|
|
docker build \
|
|
--build-arg GO_BUILDER=$${GO_BUILDER} \
|
|
--build-arg GO_VERSION=$${GO_VERSION} \
|
|
--build-arg GO_OS=$${GO_OS} \
|
|
--build-arg GO_ARCH=$${GO_ARCH} \
|
|
--build-arg GIT_HOST=$${GIT_HOST} \
|
|
--build-arg REPO_ORG=$${REPO_ORG} \
|
|
--build-arg REPO_NAME=$${REPO_NAME} \
|
|
--build-arg APP_VERSION=$${APP_VERSION} \
|
|
--build-arg COMMIT_ID=$${COMMIT_ID} \
|
|
--file dockerfile \
|
|
--tag $(IMAGE) .
|
|
|
|
dockerpush:
|
|
docker push $(IMAGE)
|
|
|
|
test:
|
|
$(GO_RUN) go test -count=1 ./...
|
|
|
|
test-race lint:
|
|
docker build --build-arg GO_BUILDER=$${GO_BUILDER} --build-arg GO_VERSION=$${GO_VERSION} --target test --file dockerfile .
|
|
|
|
integration:
|
|
scripts/integration.sh
|
|
|
|
test-e2e: docker
|
|
scripts/test-e2e.sh $(IMAGE)
|
|
|
|
test-image: docker
|
|
scripts/test-image.sh $(IMAGE) $${APP_VERSION} $${COMMIT_ID}
|
|
|
|
run:
|
|
docker compose --file compose.yaml up --build
|
|
|
|
dockerrun: docker
|
|
docker run --rm --tty --interactive \
|
|
--publish $${CONTAINER_IP}:$${CONTAINER_PORT}:8080 \
|
|
--env-file .env \
|
|
$(IMAGE)
|
|
|
|
version:
|
|
bash -c "./version.sh"
|
|
|
|
deploy:
|
|
bash -c "./deploy.sh"
|