From ccf2f433de341beee39a8e4484e0a380a09832f8 Mon Sep 17 00:00:00 2001 From: docktermj Date: Fri, 5 Jan 2024 11:10:11 -0500 Subject: [PATCH] #39 Align use of docker --- .github/workflows/docker-build-container.yaml | 16 ----- .../make-github-release-assets-darwin.yaml | 37 ----------- .../make-github-release-assets-linux.yaml | 25 -------- Dockerfile | 62 ------------------- Makefile | 39 ++++++------ README.md | 17 ----- docs/development.md | 21 ------- docs/examples.md | 5 -- go.mod | 4 +- go.sum | 8 +-- makefiles/darwin.mk | 7 ++- makefiles/linux.mk | 10 ++- makefiles/windows.mk | 5 ++ package.Dockerfile | 2 +- 14 files changed, 45 insertions(+), 213 deletions(-) delete mode 100644 .github/workflows/docker-build-container.yaml delete mode 100644 .github/workflows/make-github-release-assets-darwin.yaml delete mode 100644 .github/workflows/make-github-release-assets-linux.yaml delete mode 100755 Dockerfile diff --git a/.github/workflows/docker-build-container.yaml b/.github/workflows/docker-build-container.yaml deleted file mode 100644 index 5acc8de..0000000 --- a/.github/workflows/docker-build-container.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: docker-build-container.yaml -on: - pull_request: - branches: - - main - workflow_dispatch: -jobs: - docker-build-container: - runs-on: ubuntu-latest - steps: - - name: Build docker image - uses: senzing-factory/github-action-docker-buildx-build@latest - with: - image-repository: senzing/explain - password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - username: ${{ secrets.DOCKERHUB_USERNAME }} diff --git a/.github/workflows/make-github-release-assets-darwin.yaml b/.github/workflows/make-github-release-assets-darwin.yaml deleted file mode 100644 index 1e3745d..0000000 --- a/.github/workflows/make-github-release-assets-darwin.yaml +++ /dev/null @@ -1,37 +0,0 @@ -name: make-github-release-assets-darwin.yaml -on: - push: - tags: - - "[0-9]+.[0-9]+.[0-9]+" -permissions: write-all -jobs: - build: - name: Publish binaries - darwin - runs-on: macos-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install create-dmg - run: brew install create-dmg - - name: Make executable file - run: make darwin/amd64 - - name: Adjust create-dmg - run: | - sed -e "s|ln -s /Applications|ln -s /usr/local/bin|" /usr/local/bin/create-dmg > /usr/local/bin/create-dmg-new - mv /usr/local/bin/create-dmg /usr/local/bin/create-dmg-backup - mv /usr/local/bin/create-dmg-new /usr/local/bin/create-dmg - chmod +x /usr/local/bin/create-dmg - - name: Make a .dmg file - run: | - export BUILD_VERSION=$(git describe --always --tags --abbrev=0 --dirty | sed 's/v//') - create-dmg --app-drop-link 0 40 "explain-$BUILD_VERSION.dmg" "target/darwin-amd64/" - - name: Upload versioned package to release assets - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: "/Users/runner/work/explain/explain/explain-*" - file_glob: true - tag: ${{ github.ref }} - overwrite: true diff --git a/.github/workflows/make-github-release-assets-linux.yaml b/.github/workflows/make-github-release-assets-linux.yaml deleted file mode 100644 index efbf7a0..0000000 --- a/.github/workflows/make-github-release-assets-linux.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: make-github-release-assets.yaml -on: - push: - tags: - - "[0-9]+.[0-9]+.[0-9]+" -permissions: write-all -jobs: - build: - name: Publish binaries - linux - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Make RPM/DEB files - run: make package - - name: Upload versioned packages to release assets - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/explain-* - file_glob: true - tag: ${{ github.ref }} - overwrite: true diff --git a/Dockerfile b/Dockerfile deleted file mode 100755 index 6ca4f3a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,62 +0,0 @@ -# ----------------------------------------------------------------------------- -# Stages -# ----------------------------------------------------------------------------- - -ARG IMAGE_GO_BUILDER=golang:1.21.4-bullseye -ARG IMAGE_FINAL=senzing/senzingapi-runtime:3.8.0 - -# ----------------------------------------------------------------------------- -# Stage: go_builder -# ----------------------------------------------------------------------------- - -FROM ${IMAGE_GO_BUILDER} as go_builder -ENV REFRESHED_AT=2023-10-02 -LABEL Name="senzing/explain-builder" \ - Maintainer="support@senzing.com" \ - Version="0.2.0" - -# Copy local files from the Git repository. - -COPY ./rootfs / -COPY . ${GOPATH}/src/explain - -# Set path to Senzing libs. - -ENV LD_LIBRARY_PATH=/opt/senzing/g2/lib/ - -# Build go program. - -WORKDIR ${GOPATH}/src/explain -RUN make build - -# Copy binaries to /output. - -RUN mkdir -p /output \ - && cp -R ${GOPATH}/src/explain/target/* /output/ - -# ----------------------------------------------------------------------------- -# Stage: final -# ----------------------------------------------------------------------------- - -FROM ${IMAGE_FINAL} as final -ENV REFRESHED_AT=2023-08-01 -LABEL Name="senzing/explain" \ - Maintainer="support@senzing.com" \ - Version="0.2.0" - -# Copy local files from the Git repository. - -COPY ./rootfs / - -# Copy files from prior stage. - -COPY --from=go_builder "/output/linux-amd64/explain" "/app/explain" - -# Runtime environment variables. - -ENV LD_LIBRARY_PATH=/opt/senzing/g2/lib/ - -# Runtime execution. - -WORKDIR /app -ENTRYPOINT ["/app/explain"] diff --git a/Makefile b/Makefile index fc2a9c5..9383540 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,6 @@ dependencies: # ----------------------------------------------------------------------------- # Build -# - docker-build: https://docs.docker.com/engine/reference/commandline/build/ # ----------------------------------------------------------------------------- PLATFORMS := darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64 windows/arm64 @@ -82,14 +81,6 @@ $(PLATFORMS): .PHONY: build build: build-osarch-specific - -.PHONY: docker-build -docker-build: - @docker build \ - --tag $(DOCKER_IMAGE_NAME) \ - --tag $(DOCKER_IMAGE_NAME):$(BUILD_VERSION) \ - . - # ----------------------------------------------------------------------------- # Test # ----------------------------------------------------------------------------- @@ -101,19 +92,29 @@ test: test-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 +# ----------------------------------------------------------------------------- +# Package +# ----------------------------------------------------------------------------- + +.PHONY: docker-build-package +docker-build-package: + @docker build \ + --build-arg BUILD_ITERATION=$(BUILD_ITERATION) \ + --build-arg BUILD_VERSION=$(BUILD_VERSION) \ + --build-arg GO_PACKAGE_NAME=$(GO_PACKAGE_NAME) \ + --build-arg PROGRAM_NAME=$(PROGRAM_NAME) \ + --no-cache \ + --file package.Dockerfile \ + --tag $(DOCKER_BUILD_IMAGE_NAME) \ + . + + +.PHONY: package +package: package-osarch-specific + # ----------------------------------------------------------------------------- # Utility targets # ----------------------------------------------------------------------------- diff --git a/README.md b/README.md index 3e4cf37..f7191cc 100644 --- a/README.md +++ b/README.md @@ -95,23 +95,6 @@ senzing-tools explain [flags] 1. See [Parameters](#parameters) for additional parameters. -### Using Docker - -This usage shows how to initialze a database with a Docker container. - -1. :pencil2: Run `senzing/senzing-tools`. - Example: - - ```console - docker run \ - --env SENZING_TOOLS_COMMAND=explain \ - --env SENZING_TOOLS_ERROR_ID=senzing-60010032 \ - --rm \ - senzing/senzing-tools - ``` - -1. See [Parameters](#parameters) for additional parameters. - ### Parameters - **[LD_LIBRARY_PATH](https://github.com/senzing-garage/knowledge-base/blob/main/lists/environment-variables.md#ld_library_path)** diff --git a/docs/development.md b/docs/development.md index 3e32e8f..d885ace 100644 --- a/docs/development.md +++ b/docs/development.md @@ -97,27 +97,6 @@ Since the Senzing library is a prerequisite, it must be installed first. the reference can be found by clicking on the following badge at the top of the README.md page: [![Go Reference](https://pkg.go.dev/badge/github.com/senzing-garage/explain.svg)](https://pkg.go.dev/github.com/senzing-garage/explain) -## Docker - -1. Use make target to run a docker images that builds RPM and DEB files. - Example: - - ```console - cd ${GIT_REPOSITORY_DIR} - make docker-build - - ``` - -1. Run docker container. - Example: - - ```console - docker run \ - --rm \ - senzing/explain - - ``` - ## Package ### Package RPM and DEB files diff --git a/docs/examples.md b/docs/examples.md index 66b7748..d663a7a 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -4,8 +4,3 @@ The following examples require initialization described in [Demonstrate using Command Line Interface](../README.md#demonstrate-using-command-line-interface). - -## Examples of Docker - -The following examples require initialization described in -[Demonstrate using Docker](../README.md#demonstrate-using-docker). \ No newline at end of file diff --git a/go.mod b/go.mod index 2e2039c..4e299bd 100644 --- a/go.mod +++ b/go.mod @@ -29,8 +29,8 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20231226003508-02704c960a9b // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect + golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 96b18da..3797f76 100644 --- a/go.sum +++ b/go.sum @@ -62,11 +62,11 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/exp v0.0.0-20231226003508-02704c960a9b h1:kLiC65FbiHWFAOu+lxwNPujcsl8VYyTYYEZnsOO1WK4= -golang.org/x/exp v0.0.0-20231226003508-02704c960a9b/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= +golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/makefiles/darwin.mk b/makefiles/darwin.mk index 74e17f6..020d430 100644 --- a/makefiles/darwin.mk +++ b/makefiles/darwin.mk @@ -15,8 +15,6 @@ build-osarch-specific: darwin/amd64 .PHONY: clean-osarch-specific clean-osarch-specific: - @docker rm --force $(DOCKER_CONTAINER_NAME) 2> /dev/null || true - @docker rmi --force $(DOCKER_IMAGE_NAME) $(DOCKER_BUILD_IMAGE_NAME) 2> /dev/null || true @rm -rf $(TARGET_DIRECTORY) || true @rm -f $(GOPATH)/bin/$(PROGRAM_NAME) || true @@ -26,6 +24,11 @@ hello-world-osarch-specific: @echo "Hello World, from darwin." +.PHONY: package-osarch-specific +package-osarch-specific: + @echo No packaging for darwin. + + .PHONY: run-osarch-specific run-osarch-specific: @go run -exec macos_exec_dyld.sh main.go diff --git a/makefiles/linux.mk b/makefiles/linux.mk index 71267ac..1d1bc1b 100644 --- a/makefiles/linux.mk +++ b/makefiles/linux.mk @@ -15,8 +15,6 @@ build-osarch-specific: linux/amd64 .PHONY: clean-osarch-specific clean-osarch-specific: - @docker rm --force $(DOCKER_CONTAINER_NAME) 2> /dev/null || true - @docker rmi --force $(DOCKER_IMAGE_NAME) $(DOCKER_BUILD_IMAGE_NAME) 2> /dev/null || true @rm -rf $(TARGET_DIRECTORY) || true @rm -f $(GOPATH)/bin/$(PROGRAM_NAME) || true @@ -26,6 +24,14 @@ hello-world-osarch-specific: @echo "Hello World, from linux." +.PHONY: package-osarch-specific +package-osarch-specific: docker-build-package + @mkdir -p $(TARGET_DIRECTORY) || true + @CONTAINER_ID=$$(docker create $(DOCKER_BUILD_IMAGE_NAME)); \ + docker cp $$CONTAINER_ID:/output/. $(TARGET_DIRECTORY)/; \ + docker rm -v $$CONTAINER_ID + + .PHONY: run-osarch-specific run-osarch-specific: @go run main.go diff --git a/makefiles/windows.mk b/makefiles/windows.mk index 4c8215f..156afa6 100644 --- a/makefiles/windows.mk +++ b/makefiles/windows.mk @@ -25,6 +25,11 @@ hello-world-osarch-specific: @echo "Hello World, from windows." +.PHONY: package-osarch-specific +package-osarch-specific: + @echo No packaging for windows. + + .PHONY: run-osarch-specific run-osarch-specific: @go run main.go diff --git a/package.Dockerfile b/package.Dockerfile index 7b812c7..4e85bb7 100755 --- a/package.Dockerfile +++ b/package.Dockerfile @@ -2,7 +2,7 @@ # Stages # ----------------------------------------------------------------------------- -ARG IMAGE_GO_BUILDER=golang:1.21.0-bullseye +ARG IMAGE_GO_BUILDER=golang:1.21.4-bullseye ARG IMAGE_FPM_BUILDER=dockter/fpm:latest ARG IMAGE_FINAL=alpine