opengist/Makefile

78 lines
2.3 KiB
Makefile
Raw Normal View History

2024-05-11 19:02:57 +00:00
.PHONY: all all_crosscompile install build_frontend build_backend build build_crosscompile build_docker build_dev_docker run_dev_docker watch_frontend watch_backend watch clean clean_docker check_changes go_mod fmt test check-tr
2023-04-04 00:13:50 +00:00
# Specify the name of your Go binary output
BINARY_NAME := opengist
GIT_TAG := $(shell git describe --tags)
VERSION_PKG := github.com/thomiceli/opengist/internal/config.OpengistVersion
2023-04-04 00:13:50 +00:00
2023-09-02 22:30:57 +00:00
all: clean install build
2023-04-04 00:13:50 +00:00
all_crosscompile: clean install build_frontend build_crosscompile
2023-04-06 09:47:30 +00:00
install:
2023-04-04 00:13:50 +00:00
@echo "Installing NPM dependencies..."
@npm ci || (echo "Error: Failed to install NPM dependencies." && exit 1)
@echo "Installing Go dependencies..."
@go mod download || (echo "Error: Failed to install Go dependencies." && exit 1)
build_frontend:
@echo "Building frontend assets..."
2024-01-04 03:44:56 +00:00
npx vite -c public/vite.config.js build
@EMBED=1 npx postcss 'public/assets/embed-*.css' -c public/postcss.config.js --replace # until we can .nest { @tailwind } in Sass
2023-04-04 00:13:50 +00:00
build_backend:
@echo "Building Opengist binary..."
go build -tags fs_embed -ldflags "-X $(VERSION_PKG)=$(GIT_TAG)" -o $(BINARY_NAME) .
2023-04-06 09:47:30 +00:00
build: build_frontend build_backend
2023-04-04 00:13:50 +00:00
build_crosscompile:
@bash ./scripts/build-all.sh
2023-04-04 13:17:55 +00:00
build_docker:
@echo "Building Docker image..."
2023-04-06 09:47:30 +00:00
docker build -t $(BINARY_NAME):latest .
2024-02-19 00:58:50 +00:00
build_dev_docker:
@echo "Building Docker image..."
docker build -t $(BINARY_NAME)-dev:latest --target dev .
run_dev_docker:
docker run -v .:/opengist -p 6157:6157 -p 16157:16157 -v $(HOME)/.opengist-dev:/root/.opengist --rm $(BINARY_NAME)-dev:latest
2024-02-19 00:58:50 +00:00
2023-04-06 09:47:30 +00:00
watch_frontend:
@echo "Building frontend assets..."
2024-02-19 00:58:50 +00:00
npx vite -c public/vite.config.js dev --port 16157 --host
2023-04-06 09:47:30 +00:00
watch_backend:
@echo "Building Opengist binary..."
OG_DEV=1 npx nodemon --watch '**/*' -e html,yml,go,js --signal SIGTERM --exec 'go run -ldflags "-X $(VERSION_PKG)=$(GIT_TAG)" . --config config.yml'
2023-04-06 09:47:30 +00:00
watch:
2024-02-19 00:58:50 +00:00
@sh ./scripts/watch.sh
2023-04-04 13:17:55 +00:00
2023-04-04 00:13:50 +00:00
clean:
@echo "Cleaning up build artifacts..."
@rm -f $(BINARY_NAME) public/manifest.json
@rm -rf public/assets build
2023-04-04 00:13:50 +00:00
2023-04-04 13:17:55 +00:00
clean_docker:
@echo "Cleaning up Docker image..."
2023-04-06 09:47:30 +00:00
@docker rmi $(BINARY_NAME)
2023-09-17 00:55:17 +00:00
check_changes:
@echo "Checking for changes..."
@git --no-pager diff --exit-code || (echo "There are unstaged changes detected." && exit 1)
go_mod:
@go mod download
@go mod tidy
fmt:
@go fmt ./...
test:
@go test ./... -p 1
2024-05-11 19:02:57 +00:00
check-tr:
@bash ./scripts/check-translations.sh