-
Notifications
You must be signed in to change notification settings - Fork 361
/
Dockerfile
54 lines (44 loc) · 1.58 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# syntax=docker/dockerfile:1
ARG VERSION=dev
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 $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 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 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/
RUN $ADD_PACKAGES $IMAGE_PACKAGES
RUN addgroup -S lakefs && adduser -S lakefs -G lakefs
USER lakefs
WORKDIR /home/lakefs
ENTRYPOINT ["/app/lakectl"]
FROM lakectl AS lakefs
COPY ./scripts/wait-for /app/
COPY --from=build-lakefs /build/lakefs /app/
EXPOSE 8000/tcp
ENTRYPOINT ["/app/lakefs"]
CMD ["run"]