feat: add comprehensive Makefile for building app and Docker images
- Add targets for building TypeScript app with bun - Add multi-architecture Docker build support (amd64, arm64) - Support development (dev) and production (start) modes - Add local Docker build target for faster testing - Configure docker image registry integration - Include help target for viewing available commands - Support automated lock file updates
This commit is contained in:
61
s3-nodejs-api/Makefile
Normal file
61
s3-nodejs-api/Makefile
Normal file
@@ -0,0 +1,61 @@
|
||||
.PHONY: build build-docker build-docker-prod clean help install start dev test lock-update
|
||||
|
||||
# Variables
|
||||
IMAGE_NAME ?= media-streamer
|
||||
IMAGE_TAG ?= latest
|
||||
BUN_VERSION ?= 1.2.20
|
||||
IMAGE_REGISTRY ?= gitea-gitea-ssh.taildb3494.ts.net/will
|
||||
|
||||
help: ## Show this help message
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
lock-update: ## Update bun.lock file
|
||||
bun install
|
||||
|
||||
install: lock-update ## Install dependencies
|
||||
|
||||
build: ## Build the TypeScript app
|
||||
bun run build
|
||||
|
||||
dev: ## Start the app in development mode with watch
|
||||
bun run start:dev
|
||||
|
||||
start: build ## Build and start the app in production mode
|
||||
bun run start
|
||||
|
||||
test: ## Run tests
|
||||
bun test
|
||||
|
||||
clean: ## Clean build artifacts
|
||||
rm -rf dist/
|
||||
|
||||
build-docker: ## Build Docker image for multiple architectures (amd64, arm64)
|
||||
docker buildx build \
|
||||
--platform linux/amd64 \
|
||||
--build-arg BUN_VERSION=$(BUN_VERSION) \
|
||||
-t $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) \
|
||||
.
|
||||
|
||||
build-docker-prod: ## Build Docker image for multiple architectures with production optimizations
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--build-arg BUN_VERSION=$(BUN_VERSION) \
|
||||
-t $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) \
|
||||
--push \
|
||||
.
|
||||
|
||||
build-docker-local: ## Build Docker image for current architecture only (faster for local testing)
|
||||
docker build \
|
||||
--build-arg BUN_VERSION=$(BUN_VERSION) \
|
||||
-t $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) \
|
||||
.
|
||||
|
||||
push-docker: ## Push Docker image to registry (requires IMAGE_REGISTRY set)
|
||||
@if [ -z "$(IMAGE_REGISTRY)" ]; then \
|
||||
echo "Error: IMAGE_REGISTRY not set"; \
|
||||
exit 1; \
|
||||
fi
|
||||
docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)
|
||||
docker push $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)
|
||||
|
||||
all: clean install build build-docker ## Clean, install, build app, and build Docker image
|
||||
Reference in New Issue
Block a user