Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone 8420 to get Esti to passClone/adjust arch w build args #8438

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
# syntax=docker/dockerfile:1
ARG VERSION=dev

FROM --platform=$BUILDPLATFORM golang:1.22.6-alpine3.20 AS build
ARG BUILD_REPO=golang
ARG BUILD_TAG=1.22.6-alpine3.20
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"


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

WORKDIR /build
RUN apk add --no-cache build-base ca-certificates
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
FROM build AS build-lakefs
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
FROM build AS build-lakectl
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 alpine:3.18 AS lakectl
FROM $IMAGE_REPO:$IMAGE_TAG AS lakectl
ARG ADD_PACKAGES IMAGE_PACKAGES
WORKDIR /app
ENV PATH /app:$PATH
ENV PATH=/app:$PATH
COPY --from=build-lakectl /build/lakectl /app/
RUN apk add -U --no-cache ca-certificates
RUN $ADD_PACKAGES $IMAGE_PACKAGES
RUN addgroup -S lakefs && adduser -S lakefs -G lakefs
USER lakefs
WORKDIR /home/lakefs
Expand Down
Loading