Skip to content

Commit

Permalink
[adjust-arch-w-build-args] adjusted scope of args
Browse files Browse the repository at this point in the history
  • Loading branch information
Donlan, Christopher committed Dec 16, 2024
1 parent 72698a4 commit a642839
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,40 @@ ARG VERSION=dev

ARG BUILD_REPO=golang
ARG BUILD_TAG=1.22.6-alpine3.20
ARG BUILD_PACKAGES=build-base ca-certificates
ARG BUILD_PACKAGES="build-base ca-certificates"

ARG IMAGE_REPO=alpine
ARG IMAGE_TAG=3.18
ARG IMAGE_PACKAGES=ca-certificates

ARG ADD_PACKAGES=apk add -U --no-cache
ARG ADD_PACKAGES="apk add -U --no-cache"


FROM --platform=$BUILDPLATFORM $BUILD_REPO:$BUILD_TAG AS build
ARG ADD_PACKAGES BUILD_PACKAGES

WORKDIR /build
RUN $ADD_PACKAGES $BUILD_PACKAGES
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg go mod download
COPY . ./

FROM build AS build-lakefs
ARG VERSION TARGETOS TARGETARCH
ARG VERSION TARGETOS TARGETARCH ADD_PACKAGES BUILD_PACKAGES
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -ldflags "-X github.com/treeverse/lakefs/pkg/version.Version=${VERSION}" -o lakefs ./cmd/lakefs

FROM build AS build-lakectl
ARG VERSION TARGETOS TARGETARCH
ARG VERSION TARGETOS TARGETARCH ADD_PACKAGES BUILD_PACKAGES
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -ldflags "-X github.com/treeverse/lakefs/pkg/version.Version=${VERSION}" -o lakectl ./cmd/lakectl

FROM $IMAGE_REPO:$IMAGE_TAG AS lakectl
ARG ADD_PACKAGES IMAGE_PACKAGES
WORKDIR /app
ENV PATH=/app:$PATH
COPY --from=build-lakectl /build/lakectl /app/
Expand Down

0 comments on commit a642839

Please sign in to comment.