From 25c0f6f08b336e276c57b2f39ad87d23eeac9357 Mon Sep 17 00:00:00 2001 From: CodeJitsu42 Date: Fri, 17 May 2024 16:47:46 +0300 Subject: [PATCH 1/4] Create Dockerfile Multi-architecture Dockerfile. --- Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..38006d2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +ARG BUILDER_IMAGE=docker.io/golang:1.22 +ARG FINAL_IMAGE=docker.io/redhat/ubi9-minimal:9.4 +ARG http_proxy +ARG https_proxy +ARG no_proxy + +FROM $BUILDER_IMAGE as builder + +ENV LANG=en_US.utf8 +ENV LC_ALL=en_US.utf8 + +ARG TARGETARCH +ARG TARGETOS + +ENV GOOS=$TARGETOS +ENV GOARCH=$TARGETARCH +ENV CGO_ENABLED=0 + +COPY . . + +RUN make deps + +RUN echo "myuser:x:1001:1001::/:/xdcrDiffer" > /passwd + +RUN go build -ldflags='-s -w -extldflags "-static"' -v \ + -o xdcrDiffer main.go + +RUN chmod +x ./runDiffer.sh + +FROM $FINAL_IMAGE as final + +COPY --from=builder /go/xdcrDiffer / +COPY --from=builder /go/runDiffer.sh / +COPY --from=builder /passwd /etc/passwd + +ENTRYPOINT ["/runDiffer.sh"] + From 0f5fc90796a164dcdf0fc53b60cb308cc2663e46 Mon Sep 17 00:00:00 2001 From: CodeJitsu42 Date: Fri, 17 May 2024 17:11:56 +0300 Subject: [PATCH 2/4] Update README.md with Docker build instructions Building with docker and docker buildx for multiple platform support. --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index b5021b2..2746e19 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,32 @@ Then simply run make once the dependencies are satisfied: neil.huang@NeilsMacbookPro:~/go/src/github.com/couchbaselabs/xdcrDiffer$ make ``` +### Building with Docker + +Docker build: +``` +docker build -t xdcr-differ:1.0.0 . +``` + +#### Multiple platform using docker buildx + +Creating the builder: +(for additional configuration -> https://docs.docker.com/build/buildkit/configure/) + +CTX=mycontext +docker buildx ls | grep -w ${CTX} || docker buildx create --name ${CTX} + +Docker buildx build for local/developer machine only: +``` +docker buildx build --builder mycontext --platform "linux/arm64" --load -t xdcr-differ:1.0.0 . +``` + +Docker buildx build and image push: +``` +docker buildx build --builder mycontext --platform "linux/amd64,linux/arm64" --push -t /xdcr-differ:1.0.0 . +``` + + ### Running #### Preparing Couchbase Clusters Before running the differ to examine consistencies between two clusters, it is *highly recommended* to first set the Metadata Purge Interval to a low value, and then once that period has elapsed, run compaction on both clusters to ensure that tombstones are removed. Compaction will also ensure that the differ will only receive the minimum amount of data necessary, which will help minimize the storage requirement for the diff tool. From 0c5fc4c60535cfbef551e9900c4e6c18a5b73db3 Mon Sep 17 00:00:00 2001 From: CodeJitsu42 Date: Fri, 24 May 2024 15:04:11 +0300 Subject: [PATCH 3/4] Create .dockerignore Adding a dockerignore file --- .dockerignore | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7d6b864 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.DS_Store +.project +fileDiff/ +mutationDiff/ +source/ +target/ +xdcrDiffer +go.mod +go.sum +xdcrDiffer.log From 7c4581987d600b6766f3c96cc6d7787d54c2612e Mon Sep 17 00:00:00 2001 From: CodeJitsu42 Date: Fri, 24 May 2024 15:06:14 +0300 Subject: [PATCH 4/4] Update Dockerfile Using ubi9 instead of ubi9-minimal --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 38006d2..fe55d7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ARG BUILDER_IMAGE=docker.io/golang:1.22 -ARG FINAL_IMAGE=docker.io/redhat/ubi9-minimal:9.4 +ARG FINAL_IMAGE=docker.io/redhat/ubi9:9.4 ARG http_proxy ARG https_proxy ARG no_proxy