diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b6169..2bfbfc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,18 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Thing 6 - Thing 5 -- Thing 4 ## [1.0.1] - yyyy-mm-dd ### Added to 1.0.1 -- Thing 3 +- Thing 4 ### Fixed in 1.0.1 -- Thing 2 +- Thing 3 ## [1.0.0] - yyyy-mm-dd diff --git a/Dockerfile b/Dockerfile index e3fa870..a1fd79c 100755 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # Stages # ----------------------------------------------------------------------------- -ARG IMAGE_GO_BUILDER=golang:1.22.3-bullseye +ARG IMAGE_BUILDER=golang:1.22.3-bullseye ARG IMAGE_FINAL=senzing/senzingapi-runtime-staging:latest # ----------------------------------------------------------------------------- @@ -12,15 +12,19 @@ ARG IMAGE_FINAL=senzing/senzingapi-runtime-staging:latest FROM ${IMAGE_FINAL} as senzingapi_runtime # ----------------------------------------------------------------------------- -# Stage: go_builder +# Stage: builder # ----------------------------------------------------------------------------- -FROM ${IMAGE_GO_BUILDER} as go_builder +FROM ${IMAGE_BUILDER} as builder ENV REFRESHED_AT=2024-07-01 LABEL Name="senzing/go-builder" \ Maintainer="support@senzing.com" \ Version="0.1.0" +# Run as "root" for system installation. + +USER root + # Copy local files from the Git repository. COPY ./rootfs / @@ -57,15 +61,15 @@ LABEL Name="senzing/template-go" \ HEALTHCHECK CMD ["/app/healthcheck.sh"] USER root -# Copy local files from the Git repository. +# Install packages via apt-get. + +# Copy files from repository. COPY ./rootfs / # Copy files from prior stage. -COPY --from=go_builder "/output/linux/template-go" "/app/template-go" - -# Install packages via apt-get. +COPY --from=builder "/output/linux/template-go" "/app/template-go" # Run as non-root container diff --git a/Makefile b/Makefile index 9aace74..32f9b34 100644 --- a/Makefile +++ b/Makefile @@ -15,12 +15,13 @@ PROGRAM_NAME := $(shell basename `git rev-parse --show-toplevel`) MAKEFILE_PATH := $(abspath $(firstword $(MAKEFILE_LIST))) MAKEFILE_DIRECTORY := $(shell dirname $(MAKEFILE_PATH)) TARGET_DIRECTORY := $(MAKEFILE_DIRECTORY)/target +DIST_DIRECTORY := $(MAKEFILE_DIRECTORY)/dist +BUILD_TAG := $(shell git describe --always --tags --abbrev=0 | sed 's/v//') +BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's/^ *//') +BUILD_VERSION := $(shell git describe --always --tags --abbrev=0 --dirty | sed 's/v//') DOCKER_CONTAINER_NAME := $(PROGRAM_NAME) DOCKER_IMAGE_NAME := senzing/$(PROGRAM_NAME) DOCKER_BUILD_IMAGE_NAME := $(DOCKER_IMAGE_NAME)-build -BUILD_VERSION := $(shell git describe --always --tags --abbrev=0 --dirty | sed 's/v//') -BUILD_TAG := $(shell git describe --always --tags --abbrev=0 | sed 's/v//') -BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's/^ *//') GIT_REMOTE_URL := $(shell git config --get remote.origin.url) GIT_REPOSITORY_NAME := $(shell basename `git rev-parse --show-toplevel`) GIT_VERSION := $(shell git describe --always --tags --long --dirty | sed -e 's/\-0//' -e 's/\-g.......//') @@ -35,7 +36,9 @@ GO_ARCH = $(word 2, $(GO_OSARCH)) # Conditional assignment. ('?=') # Can be overridden with "export" +# Example: "export LD_LIBRARY_PATH=/path/to/my/senzing/g2/lib" +DOCKER_IMAGE_TAG ?= $(GIT_REPOSITORY_NAME):$(GIT_VERSION) GOBIN ?= $(shell go env GOPATH)/bin LD_LIBRARY_PATH ?= /opt/senzing/g2/lib @@ -99,7 +102,7 @@ lint: PLATFORMS := darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64 windows/arm64 $(PLATFORMS): - @echo Building $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME) + $(info Building $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME)) @GOOS=$(GO_OS) GOARCH=$(GO_ARCH) go build -o $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME) @@ -168,6 +171,20 @@ docker-run: .PHONY: run run: run-osarch-specific +# ----------------------------------------------------------------------------- +# Documentation +# ----------------------------------------------------------------------------- + +.PHONY: documentation +documentation: sphinx view-sphinx + +# ----------------------------------------------------------------------------- +# Package +# ----------------------------------------------------------------------------- + +.PHONY: package +package: clean package-osarch-specific + # ----------------------------------------------------------------------------- # Clean # ----------------------------------------------------------------------------- @@ -181,10 +198,17 @@ clean: clean-osarch-specific # Utility targets # ----------------------------------------------------------------------------- +.PHONY: docker-rmi-for-build +docker-rmi-for-build: + -docker rmi --force \ + $(DOCKER_IMAGE_NAME):$(GIT_VERSION) \ + $(DOCKER_IMAGE_NAME) + + .PHONY: help help: - @echo "Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)". - @echo "Makefile targets:" + $(info Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)) + $(info Makefile targets:) @$(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs @@ -199,3 +223,8 @@ print-make-variables: update-pkg-cache: @GOPROXY=https://proxy.golang.org GO111MODULE=on \ go get $(GO_PACKAGE_NAME)@$(BUILD_TAG) + +# ----------------------------------------------------------------------------- +# Specific programs +# ----------------------------------------------------------------------------- + \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index be6db54..a5a756d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,8 @@ # template-go -Placeholder for [GitHub pages](https://pages.github.com/). +Placeholder for [GitHub pages]. -See [https://garage.senzing.com/template-go](https://garage.senzing.com/template-go). +See [GitHub page]. + +[GitHub page]: https://garage.senzing.com/template-go +[GitHub pages]: https://pages.github.com/ diff --git a/docs/development.md b/docs/development.md index ca75855..7040a4e 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1,5 +1,10 @@ # template-go development +The following instructions are useful during development. + +**Note:** This has been tested on Linux and Darwin/macOS. +It has not been tested on Windows. + ## Install Go 1. See Go's [Download and install]. @@ -71,7 +76,7 @@ Since the Senzing library is a prerequisite, it must be installed first. ## Run -1. Run the binary. +1. Run program. Examples: 1. linux @@ -106,7 +111,7 @@ Since the Senzing library is a prerequisite, it must be installed first. ## Lint -1. Run Go tests. +1. Run linting. Example: ```console @@ -117,7 +122,7 @@ Since the Senzing library is a prerequisite, it must be installed first. ## Test -1. Run Go tests. +1. Run tests. Example: ```console @@ -145,7 +150,7 @@ Create a code coverage map. ## Documentation -1. Start [godoc] documentation server. +1. View documentation. Example: ```console @@ -191,6 +196,15 @@ Example: ``` +1. **Optional:** Test using `docker-compose`. + Example: + + ```console + cd ${GIT_REPOSITORY_DIR} + make docker-test + + ``` + ## Package ### Package RPM and DEB files diff --git a/makefiles/darwin.mk b/makefiles/darwin.mk index f4032f3..051dd06 100644 --- a/makefiles/darwin.mk +++ b/makefiles/darwin.mk @@ -7,7 +7,7 @@ SENZING_DIR ?= /opt/senzing/g2 SENZING_TOOLS_SENZING_DIRECTORY ?= $(SENZING_DIR) -LD_LIBRARY_PATH := $(SENZING_TOOLS_SENZING_DIRECTORY)/lib:$(SENZING_TOOLS_SENZING_DIRECTORY)/lib/macos +LD_LIBRARY_PATH ?= $(SENZING_TOOLS_SENZING_DIRECTORY)/lib:$(SENZING_TOOLS_SENZING_DIRECTORY)/lib/macos DYLD_LIBRARY_PATH := $(LD_LIBRARY_PATH) SENZING_TOOLS_DATABASE_URL ?= sqlite3://na:na@nowhere/tmp/sqlite/G2C.db PATH := $(MAKEFILE_DIRECTORY)/bin:/$(HOME)/go/bin:$(PATH) @@ -57,12 +57,12 @@ documentation-osarch-specific: .PHONY: hello-world-osarch-specific hello-world-osarch-specific: - @echo "Hello World, from darwin." + $(info Hello World, from darwin.) .PHONY: package-osarch-specific package-osarch-specific: - @echo No packaging for darwin. + $(info No packaging for darwin.) .PHONY: run-osarch-specific @@ -87,4 +87,4 @@ test-osarch-specific: .PHONY: only-darwin only-darwin: - @echo "Only darwin has this Makefile target." + $(info Only darwin has this Makefile target.) diff --git a/makefiles/darwin_arm64.mk b/makefiles/darwin_arm64.mk index 929ee15..5017657 100644 --- a/makefiles/darwin_arm64.mk +++ b/makefiles/darwin_arm64.mk @@ -21,4 +21,4 @@ docker-build-osarch-specific: .PHONY: only-darwin-arm64 only-darwin-arm64: - @echo "Only darwin-arm64 has this Makefile target." + $(info Only darwin-arm64 has this Makefile target.) diff --git a/makefiles/darwin_x86_64.mk b/makefiles/darwin_x86_64.mk index 6ce96f2..33af8ba 100644 --- a/makefiles/darwin_x86_64.mk +++ b/makefiles/darwin_x86_64.mk @@ -13,4 +13,4 @@ build-osarch-specific: darwin/amd64 .PHONY: only-darwin-x86_64 only-darwin-x86_64: - @echo "Only darwin-x86_64 has this Makefile target." + $(info Only darwin-x86_64 has this Makefile target.) diff --git a/makefiles/linux.mk b/makefiles/linux.mk index dc0cae2..3ef721e 100644 --- a/makefiles/linux.mk +++ b/makefiles/linux.mk @@ -54,7 +54,7 @@ docker-build-osarch-specific: .PHONY: hello-world-osarch-specific hello-world-osarch-specific: - @echo "Hello World, from linux." + $(info Hello World, from linux.) .PHONY: package-osarch-specific @@ -87,4 +87,4 @@ test-osarch-specific: .PHONY: only-linux only-linux: - @echo "Only linux has this Makefile target." + $(info Only linux has this Makefile target.) diff --git a/makefiles/linux_arm64.mk b/makefiles/linux_arm64.mk index afe03af..5c23d78 100644 --- a/makefiles/linux_arm64.mk +++ b/makefiles/linux_arm64.mk @@ -24,4 +24,4 @@ docker-build-osarch-specific: .PHONY: only-linux-arm64 only-linux-arm64: - @echo "Only linux-arm64 has this Makefile target." + $(info Only linux-arm64 has this Makefile target.) diff --git a/makefiles/linux_x86_64.mk b/makefiles/linux_x86_64.mk index 890ae03..0469668 100644 --- a/makefiles/linux_x86_64.mk +++ b/makefiles/linux_x86_64.mk @@ -15,4 +15,4 @@ build-osarch-specific: linux/amd64 .PHONY: only-linux-x86_64 only-linux-x86_64: - @echo "Only linux-x86_64 has this Makefile target." + $(info Only linux-x86_64 has this Makefile target.) diff --git a/makefiles/windows.mk b/makefiles/windows.mk index da510e4..ed1d210 100644 --- a/makefiles/windows.mk +++ b/makefiles/windows.mk @@ -49,12 +49,12 @@ docker-build-osarch-specific: .PHONY: hello-world-osarch-specific hello-world-osarch-specific: - @echo "Hello World, from windows." + $(info Hello World, from windows.) .PHONY: package-osarch-specific package-osarch-specific: - @echo No packaging for windows. + $(info No packaging for windows) .PHONY: run-osarch-specific @@ -80,4 +80,4 @@ test-osarch-specific: .PHONY: only-windows only-windows: - @echo "Only windows has this Makefile target." + $(info Only windows has this Makefile target.) diff --git a/makefiles/windows_arm64.mk b/makefiles/windows_arm64.mk index bde8009..585cdc7 100644 --- a/makefiles/windows_arm64.mk +++ b/makefiles/windows_arm64.mk @@ -14,4 +14,4 @@ build-osarch-specific: windows/arm64 .PHONY: only-windows-arm64 only-windows-arm64: - @echo "Only windows-arm64 has this Makefile target." + $(info Only windows-arm64 has this Makefile target.) diff --git a/makefiles/windows_x86_64.mk b/makefiles/windows_x86_64.mk index 39f9ac7..de1f472 100644 --- a/makefiles/windows_x86_64.mk +++ b/makefiles/windows_x86_64.mk @@ -14,4 +14,4 @@ build-osarch-specific: windows/amd64 .PHONY: only-windows-x86_64 only-windows-x86_64: - @echo "Only windows-x86_64 has this Makefile target." + $(info Only windows-x86_64 has this Makefile target.)