Skip to content

Commit 711670b

Browse files
committed
#302 Savepoint
1 parent a4a0d6e commit 711670b

23 files changed

+205
-121
lines changed

.github/workflows/go-test-linux.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [push]
55
env:
66
LD_LIBRARY_PATH: /opt/senzing/g2/lib
77
SENZING_LOG_LEVEL: TRACE
8-
SENZING_TOOLS_DATABASE_URL: "sqlite3://na:na@nowhere/tmp/sqlite/G2C.db"
8+
SENZING_TOOLS_DATABASE_URL: sqlite3://na:na@nowhere/tmp/sqlite/G2C.db
99

1010
permissions:
1111
contents: read

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ go.work
3131
# Makefile
3232
target/
3333

34+
.coverage
3435
cover.out
3536
coverage.html
3637
coverage.out

CONTRIBUTING.md

+30-20
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
Welcome to the project!
44

5-
We encourage contribution in a manner consistent with the [Code of Conduct](CODE_OF_CONDUCT.md).
5+
We encourage contribution in a manner consistent with the [Code of Conduct].
66
The following will guide you through the process.
77

88
There are a number of ways you can contribute:
99

10-
1. [Asking questions](#questions)
11-
1. [Requesting features](#feature-requests)
12-
1. [Reporting bugs](#bug-reporting)
13-
1. [Contributing code or documentation](#contributing-code-or-documentation)
10+
1. [Asking questions]
11+
1. [Requesting features]
12+
1. [Reporting bugs]
13+
1. [Contributing code or documentation]
1414

1515
## License Agreements
1616

@@ -23,19 +23,19 @@ A license agreement is not needed for submitting feature request, bug reporting,
2323
### Individual Contributor License Agreement
2424

2525
In order to contribute to this repository, an
26-
[Individual Contributor License Agreement (ICLA)](.github/senzing-individual-contributor-license-agreement.pdf)
26+
[Individual Contributor License Agreement (ICLA)]
2727
must be completed, submitted and accepted.
2828

2929
### Corporate Contributor License Agreement
3030

3131
If the contribution to this repository is on behalf of a company, a
32-
[Corporate Contributor License Agreement (CCLA)](.github/senzing-corporate-contributor-license-agreement.pdf)
32+
[Corporate Contributor License Agreement (CCLA)]
3333
must also be completed, submitted and accepted.
3434

3535
### Project License Agreement
3636

3737
The license agreement for this repository is stated in the
38-
[LICENSE](LICENSE) file.
38+
[LICENSE] file.
3939

4040
## Questions
4141

@@ -50,7 +50,7 @@ TODO: Instead, use ???
5050

5151
All feature requests are "GitHub issues".
5252
To request a feature, create a
53-
[GitHub issue](https://help.github.com/articles/creating-an-issue/)
53+
[GitHub issue]
5454
in this repository.
5555

5656
When creating an issue, there will be a choice to create a "Bug report" or a "Feature request".
@@ -59,20 +59,17 @@ Choose "Feature request".
5959
## Bug Reporting
6060

6161
All bug reports are "GitHub issues".
62-
Before reporting on a bug, check to see if it has
63-
[already been reported](https://github.com/search?q=+is%3Aissue+user%3Asenzing).
64-
To report a bug, create a
65-
[GitHub issue](https://help.github.com/articles/creating-an-issue/)
66-
in this repository.
62+
Before reporting on a bug, check to see if it has [already been reported].
63+
To report a bug, create a [GitHub issue] in this repository.
6764

6865
When creating an issue, there will be a choice to create a "Bug report" or a "Feature request".
6966
Choose "Bug report".
7067

7168
## Contributing code or documentation
7269

7370
To contribute code or documentation to the repository, you must have
74-
[License Agreements](#license-agreements) in place.
75-
This needs to be complete before a [Pull Request](#pull-requests) can be accepted.
71+
[License Agreements] in place.
72+
This needs to be complete before a [Pull Request] can be accepted.
7673

7774
### Setting up a development environment
7875

@@ -116,9 +113,22 @@ TODO:
116113
### Pull Requests
117114

118115
Code in the main branch is modified via GitHub pull request.
119-
Follow GitHub's
120-
[Creating a pull request from a branch](https://help.github.com/articles/creating-a-pull-request/)
121-
or
122-
[Creating a pull request from a fork](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) instructions.
116+
Follow GitHub's [Creating a pull request from a branch] or
117+
[Creating a pull request from a fork] instructions.
123118

124119
Accepting pull requests will be at the discretion of Senzing, Inc. and the repository owner(s).
120+
121+
[already been reported]: https://github.com/search?q=+is%3Aissue+user%3Asenzing
122+
[Asking questions]: #questions
123+
[Code of Conduct]: CODE_OF_CONDUCT.md
124+
[Contributing code or documentation]: #contributing-code-or-documentation
125+
[Corporate Contributor License Agreement (CCLA)]: .github/senzing-corporate-contributor-license-agreement.pdf
126+
[Creating a pull request from a branch]: https://help.github.com/articles/creating-a-pull-request/
127+
[Creating a pull request from a fork]: https://help.github.com/articles/creating-a-pull-request-from-a-fork/
128+
[GitHub issue]: https://help.github.com/articles/creating-an-issue/
129+
[Individual Contributor License Agreement (ICLA)]: .github/senzing-individual-contributor-license-agreement.pdf
130+
[LICENSE]: LICENSE
131+
[License Agreements]: #license-agreements
132+
[Pull Request]: #pull-requests
133+
[Reporting bugs]: #bug-reporting
134+
[Requesting features]: #feature-requests

Dockerfile

+13-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Stages
33
# -----------------------------------------------------------------------------
44

5-
ARG IMAGE_GO_BUILDER=golang:1.22.3-bullseye
5+
ARG IMAGE_BUILDER=golang:1.22.3-bullseye
66
ARG IMAGE_FINAL=senzing/senzingapi-runtime-staging:latest
77

88
# -----------------------------------------------------------------------------
@@ -12,14 +12,18 @@ ARG IMAGE_FINAL=senzing/senzingapi-runtime-staging:latest
1212
FROM ${IMAGE_FINAL} as senzingapi_runtime
1313

1414
# -----------------------------------------------------------------------------
15-
# Stage: go_builder
15+
# Stage: builder
1616
# -----------------------------------------------------------------------------
1717

18-
FROM ${IMAGE_GO_BUILDER} as go_builder
18+
FROM ${IMAGE_BUILDER} as builder
1919
ENV REFRESHED_AT=2024-07-01
20-
LABEL Name="senzing/serve-grpc-builder" \
20+
LABEL Name="senzing/go-builder" \
2121
Maintainer="[email protected]" \
22-
Version="0.6.0"
22+
Version="0.1.0"
23+
24+
# Run as "root" for system installation.
25+
26+
USER root
2327

2428
# Copy local files from the Git repository.
2529

@@ -57,13 +61,15 @@ LABEL Name="senzing/serve-grpc" \
5761
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "/app/healthcheck.sh" ]
5862
USER root
5963

60-
# Copy local files from the Git repository.
64+
# Copy files from repository.
6165

6266
COPY ./rootfs /
6367

6468
# Copy files from prior stage.
6569

66-
COPY --from=go_builder "/output/linux/serve-grpc" "/app/serve-grpc"
70+
COPY --from=builder "/output/linux/serve-grpc" "/app/serve-grpc"
71+
72+
# Run as non-root container
6773

6874
USER 1001
6975
COPY ./testdata/sqlite/G2C.db /tmp/sqlite/G2C.db

Makefile

+39-35
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Makefile for serve-grpc.
1+
# Makefile for Go project
22

33
# Detect the operating system and architecture.
44

@@ -15,12 +15,13 @@ PROGRAM_NAME := $(shell basename `git rev-parse --show-toplevel`)
1515
MAKEFILE_PATH := $(abspath $(firstword $(MAKEFILE_LIST)))
1616
MAKEFILE_DIRECTORY := $(shell dirname $(MAKEFILE_PATH))
1717
TARGET_DIRECTORY := $(MAKEFILE_DIRECTORY)/target
18+
DIST_DIRECTORY := $(MAKEFILE_DIRECTORY)/dist
19+
BUILD_TAG := $(shell git describe --always --tags --abbrev=0 | sed 's/v//')
20+
BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's/^ *//')
21+
BUILD_VERSION := $(shell git describe --always --tags --abbrev=0 --dirty | sed 's/v//')
1822
DOCKER_CONTAINER_NAME := $(PROGRAM_NAME)
1923
DOCKER_IMAGE_NAME := senzing/$(PROGRAM_NAME)
2024
DOCKER_BUILD_IMAGE_NAME := $(DOCKER_IMAGE_NAME)-build
21-
BUILD_VERSION := $(shell git describe --always --tags --abbrev=0 --dirty | sed 's/v//')
22-
BUILD_TAG := $(shell git describe --always --tags --abbrev=0 | sed 's/v//')
23-
BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's/^ *//')
2425
GIT_REMOTE_URL := $(shell git config --get remote.origin.url)
2526
GIT_REPOSITORY_NAME := $(shell basename `git rev-parse --show-toplevel`)
2627
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))
3536

3637
# Conditional assignment. ('?=')
3738
# Can be overridden with "export"
39+
# Example: "export LD_LIBRARY_PATH=/path/to/my/senzing/g2/lib"
3840

41+
DOCKER_IMAGE_TAG ?= $(GIT_REPOSITORY_NAME):$(GIT_VERSION)
3942
GOBIN ?= $(shell go env GOPATH)/bin
4043
LD_LIBRARY_PATH ?= /opt/senzing/g2/lib
4144
SENZING_TOOLS_DATABASE_URL ?= sqlite3://na:na@/tmp/sqlite/G2C.db
@@ -91,16 +94,15 @@ setup: setup-osarch-specific
9194
# -----------------------------------------------------------------------------
9295

9396
.PHONY: lint
94-
lint:
95-
@${GOBIN}/golangci-lint run --config=.github/linters/.golangci.yaml
97+
lint: golangci-lint
9698

9799
# -----------------------------------------------------------------------------
98100
# Build
99101
# -----------------------------------------------------------------------------
100102

101103
PLATFORMS := darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64 windows/arm64
102104
$(PLATFORMS):
103-
@echo Building $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME)
105+
$(info Building $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME))
104106
@GOOS=$(GO_OS) GOARCH=$(GO_ARCH) go build -o $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME)
105107

106108

@@ -111,11 +113,22 @@ build: build-osarch-specific
111113
.PHONY: docker-build
112114
docker-build: docker-build-osarch-specific
113115

114-
#docker-build:
115-
# @docker build \
116-
# --tag $(DOCKER_IMAGE_NAME) \
117-
# --tag $(DOCKER_IMAGE_NAME):$(BUILD_VERSION) \
118-
# .
116+
# -----------------------------------------------------------------------------
117+
# Run
118+
# -----------------------------------------------------------------------------
119+
120+
.PHONY: docker-run
121+
docker-run:
122+
@docker run \
123+
--interactive \
124+
--rm \
125+
--tty \
126+
--name $(DOCKER_CONTAINER_NAME) \
127+
$(DOCKER_IMAGE_NAME)
128+
129+
130+
.PHONY: run
131+
run: run-osarch-specific
119132

120133
# -----------------------------------------------------------------------------
121134
# Test
@@ -138,23 +151,6 @@ check-coverage:
138151
@go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...
139152
@${GOBIN}/go-test-coverage --config=.github/coverage/.testcoverage.yaml
140153

141-
# -----------------------------------------------------------------------------
142-
# Run
143-
# -----------------------------------------------------------------------------
144-
145-
.PHONY: docker-run
146-
docker-run:
147-
@docker run \
148-
--interactive \
149-
--rm \
150-
--tty \
151-
--name $(DOCKER_CONTAINER_NAME) \
152-
$(DOCKER_IMAGE_NAME)
153-
154-
155-
.PHONY: run
156-
run: run-osarch-specific
157-
158154
# -----------------------------------------------------------------------------
159155
# Documentation
160156
# -----------------------------------------------------------------------------
@@ -166,6 +162,10 @@ documentation: documentation-osarch-specific
166162
# Package
167163
# -----------------------------------------------------------------------------
168164

165+
.PHONY: package
166+
package: clean package-osarch-specific
167+
168+
169169
.PHONY: docker-build-package
170170
docker-build-package:
171171
@docker build \
@@ -178,10 +178,6 @@ docker-build-package:
178178
--tag $(DOCKER_BUILD_IMAGE_NAME) \
179179
.
180180

181-
182-
.PHONY: package
183-
package: package-osarch-specific
184-
185181
# -----------------------------------------------------------------------------
186182
# Clean
187183
# -----------------------------------------------------------------------------
@@ -197,8 +193,8 @@ clean: clean-osarch-specific
197193

198194
.PHONY: help
199195
help:
200-
@echo "Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)".
201-
@echo "Makefile targets:"
196+
$(info Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION))
197+
$(info Makefile targets:)
202198
@$(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
203199

204200

@@ -213,3 +209,11 @@ print-make-variables:
213209
update-pkg-cache:
214210
@GOPROXY=https://proxy.golang.org GO111MODULE=on \
215211
go get $(GO_PACKAGE_NAME)@$(BUILD_TAG)
212+
213+
# -----------------------------------------------------------------------------
214+
# Specific programs
215+
# -----------------------------------------------------------------------------
216+
217+
.PHONY: golangci-lint
218+
golangci-lint:
219+
@${GOBIN}/golangci-lint run --config=.github/linters/.golangci.yaml

README.md

+25-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ the recommendation is not to use it yet.
1919
`serve-grpc` is a command in the [senzing-tools] suite of tools.
2020
This command is a [gRPC] server application that supports requests to the Senzing SDK via network access.
2121

22-
[![Go Reference](https://pkg.go.dev/badge/github.com/senzing-garage/serve-grpc.svg)](https://pkg.go.dev/github.com/senzing-garage/serve-grpc)
23-
[![Go Report Card](https://goreportcard.com/badge/github.com/senzing-garage/serve-grpc)](https://goreportcard.com/report/github.com/senzing-garage/serve-grpc)
24-
[![License](https://img.shields.io/badge/License-Apache2-brightgreen.svg)](https://github.com/senzing-garage/serve-grpc/blob/main/LICENSE)
22+
[![Go Reference Badge]][Package reference]
23+
[![Go Report Card Badge]][Go Report Card]
24+
[![License Badge]][License]
25+
[![go-test-linux.yaml Badge]][go-test-linux.yaml]
26+
[![go-test-darwin.yaml Badge]][go-test-darwin.yaml]
27+
[![go-test-windows.yaml Badge]][go-test-windows.yaml]
2528

26-
[![go-test-linux.yaml](https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-linux.yaml/badge.svg)](https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-linux.yaml)
27-
[![go-test-darwin.yaml](https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-darwin.yaml/badge.svg)](https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-darwin.yaml)
28-
[![go-test-windows.yaml](https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-windows.yaml/badge.svg)](https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-windows.yaml)
29+
[![golangci-lint.yaml Badge]][golangci-lint.yaml]
2930

3031
## Overview
3132

@@ -147,8 +148,24 @@ This usage shows how to initialze a database with a Docker container.
147148
[Development]: docs/development.md
148149
[Errors]: docs/errors.md
149150
[Examples]: docs/examples.md
150-
[gRPC]: https://grpc.io/
151+
[Go Reference Badge]: https://pkg.go.dev/badge/github.com/senzing-garage/serve-grpc.svg
152+
[Go Report Card Badge]: https://goreportcard.com/badge/github.com/senzing-garage/serve-grpc
153+
[Go Report Card]: https://goreportcard.com/report/github.com/senzing-garage/serve-grpc
154+
[go-test-darwin.yaml Badge]: https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-darwin.yaml/badge.svg
155+
[go-test-darwin.yaml]: https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-darwin.yaml
156+
[go-test-linux.yaml Badge]: https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-linux.yaml/badge.svg
157+
[go-test-linux.yaml]: https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-linux.yaml
158+
[go-test-windows.yaml Badge]: https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-windows.yaml/badge.svg
159+
[go-test-windows.yaml]: https://github.com/senzing-garage/serve-grpc/actions/workflows/go-test-windows.yaml
160+
[golangci-lint.yaml Badge]: https://github.com/senzing-garage/serve-grpc/actions/workflows/golangci-lint.yaml/badge.svg
161+
[golangci-lint.yaml]: https://github.com/senzing-garage/serve-grpc/actions/workflows/golangci-lint.yaml
162+
[gRPC]: https://github.com/senzing-garage/knowledge-base/blob/main/WHATIS/grpc.md
163+
[License Badge]: https://img.shields.io/badge/License-Apache2-brightgreen.svg
164+
[License]: https://github.com/senzing-garage/serve-grpc/blob/main/LICENSE
165+
[Package reference]: https://pkg.go.dev/github.com/senzing-garage/serve-grpc
166+
[Senzing Garage]: https://github.com/senzing-garage
151167
[Senzing Protocol Buffer definitions]: https://github.com/senzing-garage/sz-sdk-proto
168+
[Senzing Quick Start guides]: https://docs.senzing.com/quickstart/
152169
[SENZING_TOOLS_DATABASE_URL]: https://github.com/senzing-garage/knowledge-base/blob/main/lists/environment-variables.md#senzing_tools_database_url
153170
[SENZING_TOOLS_ENABLE_ALL]: https://github.com/senzing-garage/knowledge-base/blob/main/lists/environment-variables.md#senzing_tools_enable_all
154171
[SENZING_TOOLS_ENABLE_G2CONFIG]: https://github.com/senzing-garage/knowledge-base/blob/main/lists/environment-variables.md#senzing_tools_enable_g2config
@@ -162,6 +179,7 @@ This usage shows how to initialze a database with a Docker container.
162179
[SENZING_TOOLS_GRPC_PORT]: https://github.com/senzing-garage/knowledge-base/blob/main/lists/environment-variables.md#senzing_tools_grpc_port
163180
[SENZING_TOOLS_LOG_LEVEL]: https://github.com/senzing-garage/knowledge-base/blob/main/lists/environment-variables.md#senzing_tools_log_level
164181
[senzing-tools]: https://github.com/senzing-garage/senzing-tools
182+
[Senzing]: https://senzing.com/
165183
[senzing/sz-sdk-go-core]: https://github.com/senzing-garage/sz-sdk-go-core
166184
[sz-sdk-go-grpc]: https://github.com/senzing-garage/sz-sdk-go-grpc
167185
[sz-sdk-python-grpc]: https://github.com/senzing-garage/sz-sdk-python-grpc

docs/README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# serve-grpc
1+
# template-go
22

3-
Placeholder for [GitHub pages](https://pages.github.com/).
3+
Placeholder for [GitHub pages].
44

5-
See [https://garage.senzing.com/serve-grpc](https://garage.senzing.com/serve-grpc).
5+
See [GitHub page].
6+
7+
[GitHub page]: https://garage.senzing.com/serve-grpc
8+
[GitHub pages]: https://pages.github.com/

0 commit comments

Comments
 (0)