Skip to content

Commit

Permalink
158 dockter 1 (#159)
Browse files Browse the repository at this point in the history
* #158 Savepoint

* #158 Fine tuning

* #158 Add footnotes

* #158 Add footnotes

* #158 Savepoint

* #158 Improve documentation

* #158 Improve documentation

* #158 Reorganize

* #158 Reorganize

* #158 Reorganize

* #158 Reorganize

* #158 Reorganize

* #158 Reorganize

* #158 Reorganize

* #158 Update license

* #158 Add godoc

* #158 uncomment database url
  • Loading branch information
docktermj authored Aug 2, 2024
1 parent 7fe4ed3 commit b9b5524
Show file tree
Hide file tree
Showing 23 changed files with 214 additions and 125 deletions.
10 changes: 7 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: github-actions
directory: /
schedule:
interval: "daily"
interval: daily
- package-ecosystem: docker
directory: /
schedule:
interval: daily
- package-ecosystem: gomod
directory: /
schedule:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-test-darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [pull_request, workflow_dispatch]
env:
DYLD_LIBRARY_PATH: /opt/senzing/g2/lib:/opt/senzing/g2/lib/macos
LD_LIBRARY_PATH: /opt/senzing/g2/lib:/opt/senzing/g2/lib/macos
SENZING_TOOLS_DATABASE_URL: "sqlite3://na:na@nowhere/tmp/sqlite/G2C.db"
SENZING_TOOLS_DATABASE_URL: sqlite3://na:na@nowhere/tmp/sqlite/G2C.db

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ go.work
# Makefile
target/

.coverage
cover.out
coverage.html
coverage.out
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
50 changes: 30 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

Welcome to the project!

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

There are a number of ways you can contribute:

1. [Asking questions](#questions)
1. [Requesting features](#feature-requests)
1. [Reporting bugs](#bug-reporting)
1. [Contributing code or documentation](#contributing-code-or-documentation)
1. [Asking questions]
1. [Requesting features]
1. [Reporting bugs]
1. [Contributing code or documentation]

## License Agreements

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

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

### Corporate Contributor License Agreement

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

### Project License Agreement

The license agreement for this repository is stated in the
[LICENSE](LICENSE) file.
[LICENSE] file.

## Questions

Expand All @@ -50,7 +50,7 @@ TODO: Instead, use ???

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

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

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

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

## Contributing code or documentation

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

### Setting up a development environment

Expand Down Expand Up @@ -116,9 +113,22 @@ TODO:
### Pull Requests

Code in the main branch is modified via GitHub pull request.
Follow GitHub's
[Creating a pull request from a branch](https://help.github.com/articles/creating-a-pull-request/)
or
[Creating a pull request from a fork](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) instructions.
Follow GitHub's [Creating a pull request from a branch] or
[Creating a pull request from a fork] instructions.

Accepting pull requests will be at the discretion of Senzing, Inc. and the repository owner(s).

[already been reported]: https://github.com/search?q=+is%3Aissue+user%3Asenzing
[Asking questions]: #questions
[Code of Conduct]: CODE_OF_CONDUCT.md
[Contributing code or documentation]: #contributing-code-or-documentation
[Corporate Contributor License Agreement (CCLA)]: .github/senzing-corporate-contributor-license-agreement.pdf
[Creating a pull request from a branch]: https://help.github.com/articles/creating-a-pull-request/
[Creating a pull request from a fork]: https://help.github.com/articles/creating-a-pull-request-from-a-fork/
[GitHub issue]: https://help.github.com/articles/creating-an-issue/
[Individual Contributor License Agreement (ICLA)]: .github/senzing-individual-contributor-license-agreement.pdf
[LICENSE]: LICENSE
[License Agreements]: #license-agreements
[Pull Request]: #pull-requests
[Reporting bugs]: #bug-reporting
[Requesting features]: #feature-requests
21 changes: 14 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

# -----------------------------------------------------------------------------
Expand All @@ -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 /
Expand Down Expand Up @@ -57,22 +61,25 @@ 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"
COPY --from=builder "/output/linux/template-go" "/app/template-go"

# Install packages via apt-get.
# Run as non-root container

USER 1001

# Runtime environment variables.

ENV LD_LIBRARY_PATH=/opt/senzing/g2/lib/

# Runtime execution.

USER 1001
WORKDIR /app
ENTRYPOINT ["/app/template-go"]
87 changes: 56 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ 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.......//')
GO_PACKAGE_NAME := $(shell echo $(GIT_REMOTE_URL) | sed -e 's|^git@github.com:|github.com/|' -e 's|\.git$$||' -e 's|Senzing|senzing|')
PATH := $(MAKEFILE_DIRECTORY)/bin:$(PATH)

Expand All @@ -33,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

Expand Down Expand Up @@ -63,10 +68,11 @@ hello-world: hello-world-osarch-specific
# Dependency management
# -----------------------------------------------------------------------------

.PHONY: dependencies-for-make
dependencies-for-make:
.PHONY: dependencies-for-development
dependencies-for-development:
@go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
@go install github.com/vladopajic/go-test-coverage/v2@latest
@go install golang.org/x/tools/cmd/godoc@latest
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.58.1


Expand All @@ -88,16 +94,15 @@ setup: setup-osarch-specific
# -----------------------------------------------------------------------------

.PHONY: lint
lint:
@${GOBIN}/golangci-lint run --config=.github/linters/.golangci.yaml
lint: golangci-lint

# -----------------------------------------------------------------------------
# Build
# -----------------------------------------------------------------------------

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)


Expand Down Expand Up @@ -128,13 +133,35 @@ build-scratch:
.PHONY: docker-build
docker-build: docker-build-osarch-specific

# -----------------------------------------------------------------------------
# Run
# -----------------------------------------------------------------------------

.PHONY: docker-run
docker-run:
@docker run \
--interactive \
--rm \
--tty \
--name $(DOCKER_CONTAINER_NAME) \
$(DOCKER_IMAGE_NAME)


.PHONY: run
run: run-osarch-specific

# -----------------------------------------------------------------------------
# Test
# -----------------------------------------------------------------------------

.PHONY: test
test: test-osarch-specific


.PHONY: docker-test
docker-test:
@docker-compose -f docker-compose.test.yaml up

# -----------------------------------------------------------------------------
# Coverage
# -----------------------------------------------------------------------------
Expand All @@ -149,23 +176,6 @@ check-coverage:
@go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...
@${GOBIN}/go-test-coverage --config=.github/coverage/.testcoverage.yaml

# -----------------------------------------------------------------------------
# Run
# -----------------------------------------------------------------------------

.PHONY: docker-run
docker-run:
@docker run \
--interactive \
--rm \
--tty \
--name $(DOCKER_CONTAINER_NAME) \
$(DOCKER_IMAGE_NAME)


.PHONY: run
run: run-osarch-specific

# -----------------------------------------------------------------------------
# Documentation
# -----------------------------------------------------------------------------
Expand All @@ -177,6 +187,10 @@ documentation: documentation-osarch-specific
# Package
# -----------------------------------------------------------------------------

.PHONY: package
package: clean package-osarch-specific


.PHONY: docker-build-package
docker-build-package:
@docker build \
Expand All @@ -189,10 +203,6 @@ docker-build-package:
--tag $(DOCKER_BUILD_IMAGE_NAME) \
.


.PHONY: package
package: package-osarch-specific

# -----------------------------------------------------------------------------
# Clean
# -----------------------------------------------------------------------------
Expand All @@ -206,10 +216,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


Expand All @@ -224,3 +241,11 @@ print-make-variables:
update-pkg-cache:
@GOPROXY=https://proxy.golang.org GO111MODULE=on \
go get $(GO_PACKAGE_NAME)@$(BUILD_TAG)

# -----------------------------------------------------------------------------
# Specific programs
# -----------------------------------------------------------------------------

.PHONY: golangci-lint
golangci-lint:
@${GOBIN}/golangci-lint run --config=.github/linters/.golangci.yaml
Loading

0 comments on commit b9b5524

Please sign in to comment.