mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-01-14 19:32:29 +00:00
feat: add makefile to simplify development
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
# binaries
|
# binaries
|
||||||
/tinyauth
|
/tinyauth
|
||||||
|
/tinyauth-arm64
|
||||||
|
/tinyauth-amd64
|
||||||
|
|
||||||
# test docker compose
|
# test docker compose
|
||||||
/docker-compose.test*
|
/docker-compose.test*
|
||||||
@@ -22,9 +24,6 @@
|
|||||||
# tmp directory
|
# tmp directory
|
||||||
/tmp
|
/tmp
|
||||||
|
|
||||||
# version files
|
|
||||||
/internal/assets/version
|
|
||||||
|
|
||||||
# data directory
|
# data directory
|
||||||
/data
|
/data
|
||||||
|
|
||||||
@@ -36,4 +35,4 @@
|
|||||||
/resources
|
/resources
|
||||||
|
|
||||||
# debug files
|
# debug files
|
||||||
__debug_*
|
__debug_*
|
||||||
|
|||||||
64
Makefile
Normal file
64
Makefile
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
# Go specific stuff
|
||||||
|
CGO_ENABLED := 0
|
||||||
|
GOOS := $(shell go env GOOS)
|
||||||
|
GOARCH := $(shell go env GOARCH)
|
||||||
|
|
||||||
|
# Build out
|
||||||
|
TAG_NAME := $(shell git describe --abbrev=0 --exact-match 2> /dev/null || echo "main")
|
||||||
|
COMMIT_HASH := $(shell git rev-parse HEAD)
|
||||||
|
BUILD_TIMESTAMP := $(shell date '+%Y-%m-%dT%H:%M:%S')
|
||||||
|
BIN_NAME := tinyauth-$(GOARCH)
|
||||||
|
|
||||||
|
# Development vars
|
||||||
|
DEV_COMPOSE := $(shell test -f "docker-compose.test.yml" && echo "docker-compose.test.yml" || echo "docker-compose.yml" )
|
||||||
|
PROD_COMPOSE := $(shell test -f "docker-compose.test.prod.yml" && echo "docker-compose.test.prod.yml" || echo "docker-compose.example.yml" )
|
||||||
|
|
||||||
|
# Deps
|
||||||
|
deps:
|
||||||
|
bun install --cwd frontend
|
||||||
|
go mod download
|
||||||
|
|
||||||
|
# Clean web UI build
|
||||||
|
clean-webui:
|
||||||
|
rm -rf internal/assets/dist
|
||||||
|
rm -rf frontend/dist
|
||||||
|
|
||||||
|
# Build the web UI
|
||||||
|
webui: clean-webui
|
||||||
|
bun run --cwd frontend build
|
||||||
|
cp -r frontend/dist internal/assets
|
||||||
|
|
||||||
|
# Build the binary
|
||||||
|
binary: webui
|
||||||
|
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags "-s -w \
|
||||||
|
-X tinyauth/internal/config.Version=${TAG_NAME} \
|
||||||
|
-X tinyauth/internal/config.CommitHash=${COMMIT_HASH} \
|
||||||
|
-X tinyauth/internal/config.BuildTimestamp=${BUILD_TIMESTAMP}" \
|
||||||
|
-o ${BIN_NAME} ./cmd/tinyauth
|
||||||
|
|
||||||
|
# Build for amd64
|
||||||
|
binary-linux-amd64:
|
||||||
|
export BIN_NAME=tinyauth-amd64
|
||||||
|
export GOARCH=amd64
|
||||||
|
export GOOS=linux
|
||||||
|
$(MAKE) binary
|
||||||
|
|
||||||
|
# Build for arm64
|
||||||
|
binary-linux-arm64:
|
||||||
|
export BIN_NAME=tinyauth-arm64
|
||||||
|
export GOARCH=arm64
|
||||||
|
export GOOS=linux
|
||||||
|
$(MAKE) binary
|
||||||
|
|
||||||
|
# Go test
|
||||||
|
.PHONY: test
|
||||||
|
test:
|
||||||
|
go test -v ./...
|
||||||
|
|
||||||
|
# Development
|
||||||
|
develop:
|
||||||
|
docker compose -f $(DEV_COMPOSE) up --force-recreate --pull=always --remove-orphans
|
||||||
|
|
||||||
|
# Production
|
||||||
|
prod:
|
||||||
|
docker compose -f $(PROD_COMPOSE) up --force-recreate --pull=always --remove-orphans
|
||||||
Reference in New Issue
Block a user