Skip to content

Commit

Permalink
K8SPSMDB-948: Multi arch build
Browse files Browse the repository at this point in the history
An easy way to build PSMDB for different architectures.

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
  • Loading branch information
sergelogvinov committed Oct 13, 2023
1 parent 7f6cdbe commit bee3cde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ WORKDIR /go/src/github.com/percona/percona-server-mongodb-operator

COPY . .

ARG TARGETARCH

ARG GIT_COMMIT
ARG GIT_BRANCH
ARG GO_LDFLAGS
ARG GOOS=linux
ARG GOARCH=amd64
ARG GOARCH=${TARGETARCH}
ARG CGO_ENABLED=0

RUN go mod download \
Expand Down
13 changes: 8 additions & 5 deletions e2e-tests/build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ fi
if [[ ${DOCKER_SQUASH:-1} == 1 ]]; then
squash="--squash"
fi
if [[ ${DOCKER_PUSH:-1} == 1 ]]; then
imgresult="--push=true"
else
imgresult="--output type=docker"
fi

build_operator() {
if [ "${RELEASE:-1}" = 0 ]; then
Expand All @@ -24,18 +29,16 @@ build_operator() {
export DOCKER_DEFAULT_PLATFORM=${DOCKER_DEFAULT_PLATFORM:-linux/amd64}
export GO_LDFLAGS="-w -s -trimpath $GO_LDFLAGS"
pushd ${src_dir}
docker build \
docker buildx build \
--platform $DOCKER_DEFAULT_PLATFORM \
--build-arg GIT_COMMIT=$GIT_COMMIT \
--build-arg GIT_BRANCH=$GIT_BRANCH \
--build-arg GO_LDFLAGS="$GO_LDFLAGS" \
$squash \
$no_cache \
$imgresult \
-t "${IMAGE}" -f build/Dockerfile .
popd

if [ "${DOCKER_PUSH:-1}" = 1 ]; then
docker push ${IMAGE}
fi
}

until docker ps; do sleep 1; done
Expand Down

0 comments on commit bee3cde

Please sign in to comment.