| GO ?= go |
| GOFMT ?= gofmt |
| GO_FILES := $(wildcard *.go e2e/*.go) |
| |
| repo_name ?= giolekva |
| podman ?= docker |
| docker_flags=--provenance=false --sbom=false |
| |
| .PHONY: clean format format-check test test-race vet check test-e2e test-e2e-offline clean-e2e-artifacts build build_arm64 build_amd64 push_arm64 push_amd64 push |
| ifeq ($(podman), podman) |
| manifest_dest=docker://docker.io/$(repo_name)/auth-ui:latest |
| endif |
| |
| clean: |
| rm -f server server_* |
| |
| format: |
| $(GOFMT) -w $(GO_FILES) |
| |
| format-check: |
| @files="$$( $(GOFMT) -l $(GO_FILES) )" || { status=$$?; printf 'gofmt check failed\n' >&2; exit $$status; }; \ |
| if [ -n "$$files" ]; then printf 'Go files need formatting:\n%s\n' "$$files" >&2; exit 1; fi |
| |
| test: |
| $(GO) test ./... |
| |
| test-race: |
| $(GO) test -race -count=1 ./... |
| |
| vet: |
| $(GO) vet ./... |
| |
| check: format-check test test-race vet |
| $(GO) build ./... |
| |
| test-e2e: |
| $(GO) test -tags=e2e -count=1 -timeout=10m -v ./e2e |
| |
| test-e2e-offline: |
| AUTH_UI_E2E_OFFLINE=1 $(GO) test -tags=e2e -count=1 -timeout=10m -v ./e2e |
| |
| clean-e2e-artifacts: |
| rm -rf -- e2e/artifacts |
| |
| build: clean |
| $(GO) build -o server *.go |
| |
| build_arm64: export CGO_ENABLED=0 |
| build_arm64: export GO111MODULE=on |
| build_arm64: export GOOS=linux |
| build_arm64: export GOARCH=arm64 |
| build_arm64: |
| $(GO) build -o server_arm64 *.go |
| |
| build_amd64: export CGO_ENABLED=0 |
| build_amd64: export GO111MODULE=on |
| build_amd64: export GOOS=linux |
| build_amd64: export GOARCH=amd64 |
| build_amd64: |
| $(GO) build -o server_amd64 *.go |
| |
| push_arm64: clean build_arm64 |
| $(podman) build --platform linux/arm64 --tag=$(repo_name)/auth-ui:arm64 $(docker_flags) . |
| $(podman) push $(repo_name)/auth-ui:arm64 |
| |
| push_amd64: clean build_amd64 |
| $(podman) build --platform linux/amd64 --tag=$(repo_name)/auth-ui:amd64 $(docker_flags) . |
| $(podman) push $(repo_name)/auth-ui:amd64 |
| |
| |
| push: push_arm64 push_amd64 |
| $(podman) manifest create $(repo_name)/auth-ui:latest $(repo_name)/auth-ui:arm64 $(repo_name)/auth-ui:amd64 |
| $(podman) manifest push --purge $(repo_name)/auth-ui:latest $(manifest_dest) |