diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-03 15:53:00 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-03 15:53:00 -0600 |
| commit | c783af99f9f3da740f553e7c9cbc768fd2a89724 (patch) | |
| tree | 944f6f2d887646d6668535b1dc723bf297798816 /Makefile | |
| parent | 8f2d083fb29b5dbd5bbe185119efd4246a818f65 (diff) | |
chore: include envoy in docker image
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 43 |
1 files changed, 32 insertions, 11 deletions
@@ -1,15 +1,17 @@ -PROJECT_NAME := $(shell basename $(shell pwd)) +PROJECT_NAME := $(shell basename $(shell pwd))# {{{}}} GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') IMAGE_TAG := $(PROJECT_NAME):$(GIT_BRANCH) .PHONY: build check test run clean fmt lint doc vendor -.PHONY: build-image run-image health-check list-services test-grpc +.PHONY: build-image run-image health-check list-services test-image setup: - @rustup component add clippy rustfmt + mise install + mise exec go -- go install github.com/mattn/goreman@latest + mise exec rustup -- rustup component add clippy rustfmt # Cargo targets -build: vendor +build: @cargo build --offline check: @@ -18,8 +20,9 @@ check: test: @cargo test -run: - @cargo run --offline +run: build + @cp target/debug/authzd bin/authzd + @goreman -set-ports=false -rpc-server=false -f ./Procfile -exit-on-error=true start clean: @cargo clean @@ -37,18 +40,36 @@ vendor: @cargo vendor # Docker targets -build-image: vendor +build-image: @docker build --tag $(IMAGE_TAG) . build-image-clean: - @docker build --no-cache --tag $(IMAGE_TAG) . + @docker build --tag $(IMAGE_TAG) . run-image: build-image - @docker run --rm -p 50051:50051 --init -it $(IMAGE_TAG) + @docker run --rm -p 10000:10000 -p 9901:9901 --init -it $(IMAGE_TAG) -# gRPC testing targets +# HTTP and gRPC testing targets health-check: - @grpcurl -plaintext localhost:50051 grpc.health.v1.Health/Check + @curl -s http://localhost:10000/health || echo "Service not running" + +envoy-admin: + @curl -s http://localhost:9901/stats/prometheus | head -20 list-services: @grpcurl -plaintext localhost:50051 list + +test-image: build-image + @echo "Starting container..." + @docker run -d --name authzd-test -p 10000:10000 -p 9901:9901 $(IMAGE_TAG) + @echo "Waiting for services to start..." + @sleep 5 + @echo "Testing Envoy admin endpoint..." + @curl -s http://localhost:9901/stats/prometheus | grep -q "envoy_" && echo "✓ Envoy admin is accessible" || echo "✗ Envoy admin failed" + @echo "Testing health endpoint..." + @curl -s -o /dev/null -w "%{http_code}" http://localhost:10000/health | grep -q "200" && echo "✓ Health check passed" || echo "✗ Health check failed" + @echo "Testing authorization flow..." + @curl -s -H "Authorization: Bearer valid-token" http://localhost:10000/ -w "\n%{http_code}" | grep -q "200" && echo "✓ Auth with valid token passed" || echo "✗ Auth with valid token failed" + @curl -s http://localhost:10000/ -w "\n%{http_code}" | grep -q "401" && echo "✓ Auth without token correctly rejected" || echo "✗ Auth without token failed" + @echo "Cleaning up..." + @docker stop authzd-test && docker rm authzd-test |
