-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
85 lines (67 loc) · 3.29 KB
/
Dockerfile
File metadata and controls
85 lines (67 loc) · 3.29 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
FROM golang:1.25-bookworm AS builder-base
# -----------------------------------------------------------------------------
# Go builder
# -----------------------------------------------------------------------------
FROM builder-base AS builder-go
WORKDIR /lake
COPY . .
RUN mkdir -p bin/
# Set build arguments
ARG BUILD_VERSION=undefined
ARG BUILD_COMMIT=undefined
ARG BUILD_DATE=undefined
RUN if [ "${BUILD_VERSION}" = "undefined" ] || [ "${BUILD_COMMIT}" = "undefined" ] || [ "${BUILD_DATE}" = "undefined" ]; then \
echo "Build arguments must be defined" && \
exit 1; \
fi
ENV CGO_ENABLED=0
ENV GO_LDFLAGS="-X main.version=${BUILD_VERSION} -X main.commit=${BUILD_COMMIT} -X main.date=${BUILD_DATE}"
# Set up a binaries directory
ENV BIN_DIR=/lake/bin
RUN mkdir -p ${BIN_DIR}
# Build lake-indexer (golang)
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=1 go build -ldflags "${GO_LDFLAGS}" -o ${BIN_DIR}/lake-indexer ./indexer/cmd/indexer/main.go
# Build lake-admin (golang)
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=1 go build -ldflags "${GO_LDFLAGS}" -o ${BIN_DIR}/lake-admin ./admin/cmd/admin/main.go
# Build lake-api (golang)
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=1 go build -ldflags "${GO_LDFLAGS}" -o ${BIN_DIR}/lake-api ./api/main.go
# Force COPY in later stages to always copy the binaries, even if they appear to be the same.
ARG CACHE_BUSTER=1
RUN echo "$CACHE_BUSTER" > ${BIN_DIR}/.cache-buster && \
find ${BIN_DIR} -type f -exec touch {} +
# ----------------------------------------------------------------------------
# Main stage with only the binaries.
# ----------------------------------------------------------------------------
FROM ubuntu:24.04
# Swap to the Azure-hosted Ubuntu mirror — GitHub-hosted runners are on Azure
# and the default archive.ubuntu.com mirror is much slower from there.
RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|http://azure.archive.ubuntu.com/ubuntu/|g; s|http://security.ubuntu.com/ubuntu/|http://azure.archive.ubuntu.com/ubuntu/|g' /etc/apt/sources.list.d/ubuntu.sources
# Install build dependencies and other utilities
RUN apt update -qq && \
apt install --no-install-recommends -y \
ca-certificates \
curl \
gnupg \
build-essential \
pkg-config \
iproute2 iputils-ping net-tools tcpdump \
postgresql-client && \
# Install ClickHouse client
curl -fsSL https://packages.clickhouse.com/rpm/lts/repodata/repomd.xml.key | gpg --dearmor -o /usr/share/keyrings/clickhouse-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg] https://packages.clickhouse.com/deb stable main" > /etc/apt/sources.list.d/clickhouse.list && \
apt update -qq && \
apt install --no-install-recommends -y clickhouse-client && \
rm -rf /var/lib/apt/lists/*
ENV PATH="/lake/bin:${PATH}"
# Copy binaries from the builder stage.
COPY --from=builder-go /lake/bin/. /lake/bin/.
# Copy pre-built web assets (built by deploy script, uploaded to S3)
COPY web/dist /lake/web/dist
RUN test -f /lake/web/dist/index.html || (echo "Error: web assets not built. Run 'cd web && bun run build' first." && exit 1)
CMD ["/bin/bash"]