2023-09-26 15:13:58 +02:00
|
|
|
.PHONY: all all_crosscompile install build_frontend build_backend build build_crosscompile build_docker watch_frontend watch_backend watch clean clean_docker check_changes go_mod fmt test
|
2023-04-04 02:13:50 +02:00
|
|
|
|
|
|
|
# Specify the name of your Go binary output
|
|
|
|
BINARY_NAME := opengist
|
|
|
|
|
2023-09-03 00:30:57 +02:00
|
|
|
all: clean install build
|
2023-04-04 02:13:50 +02:00
|
|
|
|
2023-09-26 15:13:58 +02:00
|
|
|
all_crosscompile: clean install build_frontend build_crosscompile
|
|
|
|
|
2023-04-06 11:47:30 +02:00
|
|
|
install:
|
2023-04-04 02:13:50 +02: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..."
|
2023-06-21 18:18:07 +02:00
|
|
|
npx vite build
|
2023-12-21 20:00:04 +01:00
|
|
|
EMBED=1 npx postcss 'public/assets/embed-*.css' -c postcss.config.js --replace # until we can .nest { @tailwind } in Sass
|
2023-04-04 02:13:50 +02:00
|
|
|
|
|
|
|
build_backend:
|
|
|
|
@echo "Building Opengist binary..."
|
2023-04-06 11:47:30 +02:00
|
|
|
go build -tags fs_embed -o $(BINARY_NAME) .
|
|
|
|
|
|
|
|
build: build_frontend build_backend
|
2023-04-04 02:13:50 +02:00
|
|
|
|
2023-09-26 15:13:58 +02:00
|
|
|
build_crosscompile:
|
|
|
|
@bash ./scripts/build-all.sh
|
|
|
|
|
2023-04-04 15:17:55 +02:00
|
|
|
build_docker:
|
|
|
|
@echo "Building Docker image..."
|
2023-04-06 11:47:30 +02:00
|
|
|
docker build -t $(BINARY_NAME):latest .
|
|
|
|
|
|
|
|
watch_frontend:
|
|
|
|
@echo "Building frontend assets..."
|
2023-06-21 18:18:07 +02:00
|
|
|
npx vite dev --port 16157
|
2023-04-06 11:47:30 +02:00
|
|
|
|
|
|
|
watch_backend:
|
|
|
|
@echo "Building Opengist binary..."
|
2023-06-21 18:18:07 +02:00
|
|
|
OG_DEV=1 npx nodemon --watch '**/*' -e html,yml,go,js --signal SIGTERM --exec 'go run . --config config.yml'
|
2023-04-06 11:47:30 +02:00
|
|
|
|
|
|
|
watch:
|
2023-09-26 15:13:58 +02:00
|
|
|
@bash ./scripts/watch.sh
|
2023-04-04 15:17:55 +02:00
|
|
|
|
2023-04-04 02:13:50 +02:00
|
|
|
clean:
|
|
|
|
@echo "Cleaning up build artifacts..."
|
|
|
|
@rm -f $(BINARY_NAME) public/manifest.json
|
2023-09-26 15:13:58 +02:00
|
|
|
@rm -rf public/assets build
|
2023-04-04 02:13:50 +02:00
|
|
|
|
2023-04-04 15:17:55 +02:00
|
|
|
clean_docker:
|
|
|
|
@echo "Cleaning up Docker image..."
|
2023-04-06 11:47:30 +02:00
|
|
|
@docker rmi $(BINARY_NAME)
|
2023-09-17 02:55:17 +02: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
|