Skip to content

Commit

Permalink
#158 Savepoint
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj committed Aug 2, 2024
1 parent 8cff2ba commit b3f4b63
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 37 deletions.
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
18 changes: 11 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,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

Expand Down
41 changes: 35 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.......//')
Expand All @@ -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

Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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
# -----------------------------------------------------------------------------
Expand All @@ -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


Expand All @@ -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
# -----------------------------------------------------------------------------

7 changes: 5 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -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/
22 changes: 18 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -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].
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -145,7 +150,7 @@ Create a code coverage map.

## Documentation

1. Start [godoc] documentation server.
1. View documentation.
Example:

```console
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions makefiles/darwin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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.)
2 changes: 1 addition & 1 deletion makefiles/darwin_arm64.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
2 changes: 1 addition & 1 deletion makefiles/darwin_x86_64.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
4 changes: 2 additions & 2 deletions makefiles/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.)
2 changes: 1 addition & 1 deletion makefiles/linux_arm64.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
2 changes: 1 addition & 1 deletion makefiles/linux_x86_64.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
6 changes: 3 additions & 3 deletions makefiles/windows.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.)
2 changes: 1 addition & 1 deletion makefiles/windows_arm64.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
2 changes: 1 addition & 1 deletion makefiles/windows_x86_64.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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.)

0 comments on commit b3f4b63

Please sign in to comment.