-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapted for go mod and vendored some libs:
- added Makefile for easy build - added future build build bin in container - added future bulld packages in container - adapted for go mod - vendored some library
- Loading branch information
Showing
32 changed files
with
520 additions
and
2,776 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
pkg | ||
pkgs_out | ||
bin | ||
.prepared_cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
FROM gliderlabs/alpine:3.2 | ||
|
||
MAINTAINER Ryan Eschinger <[email protected]> | ||
|
||
COPY . /go/src/github.com/outbrain/zookeepercli/ | ||
|
||
RUN apk add --update go git \ | ||
&& cd /go/src/github.com/outbrain/zookeepercli/ \ | ||
&& export GOPATH=/go \ | ||
&& go get \ | ||
&& go build -o /bin/zookeepercli \ | ||
&& rm -rf /go \ | ||
&& apk del --purge go git | ||
# syntax=docker/dockerfile:experimental | ||
|
||
FROM scratch | ||
COPY bin/zookeepercli /bin/zookeepercli | ||
ENTRYPOINT ["/bin/zookeepercli"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
.PHONY: clean | ||
|
||
BINARY_NAME ?= zookeepercli | ||
VERSION ?= $(shell git describe --long --tags --always --dirty --abbrev=10) | ||
GOLANG_VERSION ?= 1.21-alpine | ||
|
||
CURRENT_DIR := $(shell pwd) | ||
|
||
DOCKER ?= docker | ||
|
||
.prepare_cmd: | ||
printf "go build -o ./bin/%s -ldflags \"-X 'main.Version=%s'\"\n" "$(BINARY_NAME)" "$(VERSION)" > .prepared_cmd | ||
|
||
# build bin in docker, package in docker and build the docker image | ||
all_in_docker: package_in_docker build_docker_image | ||
@echo "All done" | ||
|
||
# build bin and package locally | ||
all: package | ||
@echo "All done" | ||
|
||
build: .prepare_cmd | ||
sh .prepared_cmd | ||
|
||
package: build | ||
@ /bin/sh ./scripts/build_package.sh | ||
@ echo "=== Packaged files: ===" | ||
@ echo "==== in ./pkgs_out ====" | ||
@ ls -1 ./pkgs_out | ||
@ echo "=======================" | ||
|
||
build_in_docker: .prepare_cmd | ||
${DOCKER} run --rm -t -v "$(CURRENT_DIR):/app" -w /app \ | ||
-e CGO_ENABLED=0 \ | ||
golang:$(GOLANG_VERSION) /bin/sh .prepared_cmd | ||
|
||
package_in_docker: build_in_docker | ||
${DOCKER} run --rm -t -v "$(CURRENT_DIR):/app" -w /app \ | ||
-e CGO_ENABLED=0 \ | ||
golang:$(GOLANG_VERSION) \ | ||
/bin/sh -c \ | ||
"/bin/sh ./scripts/prepare_container.sh && /bin/sh ./scripts/build_package.sh" | ||
@ echo "=== Packaged files: ===" | ||
@ echo "==== in ./pkgs_out ====" | ||
@ ls -1 ./pkgs_out | ||
@ echo "=======================" | ||
|
||
build_docker_image: build_in_docker | ||
${DOCKER} build -t zookeepercli:$(VERSION) -t zookeepercli:latest . | ||
|
||
clean: | ||
rm -rf ./bin | ||
rm -rf ./pkgs_out | ||
rm -rf .prepared_cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module github.com/openark/zookeepercli | ||
|
||
go 1.21.5 | ||
|
||
require ( | ||
github.com/outbrain/golib v0.0.0-20200503083229-2531e5dbcc71 | ||
github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github.com/outbrain/golib v0.0.0-20200503083229-2531e5dbcc71 h1:5FSwz/q8DhpkUsq8cqRN7gRVWWnfXfjeOeB8Bhj5ARc= | ||
github.com/outbrain/golib v0.0.0-20200503083229-2531e5dbcc71/go.mod h1:JDhu//MMvcPVPH889Xr7DyamEbTLumgDBALGUyXrz1g= | ||
github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414 h1:AJNDS0kP60X8wwWFvbLPwDuojxubj9pbfK7pjHw0vKg= | ||
github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh -e | ||
# Build deb package for zookeepercli | ||
# Sergei Kraev <[email protected]> | ||
# | ||
|
||
echo "========= Preparing packing start ========="; | ||
PKGNAME="zookeepercli" | ||
VER=$(git describe --long --tags --always --abbrev=10 | sed 's/^[^0-9]//ig') | ||
ARCH=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) | ||
RDIR="$(pwd)/pkgs_out/" | ||
|
||
rm -rf "${RDIR}" | ||
mkdir -p "$RDIR" | ||
|
||
OUTTYPES="rpm deb apk tar zip" | ||
|
||
for OUTTYPE in $OUTTYPES; do | ||
echo "========= Packing ${OUTTYPE} start ========="; | ||
fpm \ | ||
--output-type "${OUTTYPE}" \ | ||
--input-type dir \ | ||
--force \ | ||
\ | ||
--name "${PKGNAME}" \ | ||
--package "${RDIR}" \ | ||
--version "${VER}" \ | ||
--architecture "${ARCH}" \ | ||
--maintainer 'Shlomi Noach <[email protected]>' \ | ||
--url 'https://github.com/openark/zookeepercli' \ | ||
--description 'Zookeeper client console' \ | ||
--license 'Apache 2.0' \ | ||
--category 'universe/net' \ | ||
--no-depends --no-auto-depends \ | ||
--prefix /usr/local/bin \ | ||
--chdir "./bin" . | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh -e | ||
# Build deb package for zookeepercli | ||
# Sergei Kraev <[email protected]> | ||
# | ||
|
||
echo "========= Preparing packing start ========="; | ||
apk update | ||
apk add --no-cache \ | ||
git \ | ||
ruby \ | ||
rpm-dev \ | ||
tar \ | ||
zip | ||
|
||
git config --global --add safe.directory "$(pwd)" | ||
gem install fpm |
Oops, something went wrong.