-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (54 loc) · 1.7 KB
/
Dockerfile
File metadata and controls
70 lines (54 loc) · 1.7 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
# Multi-stage Dockerfile for building helm_sdkpy with bundled dependencies
# This creates a self-contained Python wheel with embedded Helm Go library
# Stage 1: Build environment with all dependencies
FROM ubuntu:24.04 AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
ca-certificates \
# Go compiler
golang-1.22 \
# Python build tools
python3 \
python3-dev \
python3-pip \
python3-venv \
&& rm -rf /var/lib/apt/lists/*
# Set up Go environment
ENV PATH="/usr/lib/go-1.22/bin:${PATH}"
ENV GOPATH="/go"
ENV PATH="${GOPATH}/bin:${PATH}"
WORKDIR /build
# Copy source code
COPY . .
# Stage 2: Build Go shim as shared library
FROM builder AS go-build
WORKDIR /build/go
# Download Go dependencies
RUN go mod download && go mod tidy
# Build the Go shared library
RUN mkdir -p /build/helm_sdkpy/_lib/linux-amd64 && \
cd shim && \
go build -buildmode=c-shared \
-o /build/helm_sdkpy/_lib/linux-amd64/libhelm_sdkpy.so \
.
# Verify the shared library was built
RUN ls -lh /build/helm_sdkpy/_lib/linux-amd64/libhelm_sdkpy.so && \
ldd /build/helm_sdkpy/_lib/linux-amd64/libhelm_sdkpy.so || true
# Stage 3: Build Python wheel
FROM go-build AS wheel-build
WORKDIR /build
# Install UV for fast Python package management
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:${PATH}"
# Build the wheel
RUN uv build
# List built wheel and sdist
RUN ls -lh dist/
# Stage 4: Extract artifacts
FROM scratch AS artifacts
COPY --from=wheel-build /build/dist/*.whl /
COPY --from=wheel-build /build/dist/*.tar.gz /
COPY --from=go-build /build/helm_sdkpy/_lib/linux-amd64/libhelm_sdkpy.so /