Skip to content

Commit bb4f31d

Browse files
committed
attempt fix celestia build
1 parent cb0f11a commit bb4f31d

9 files changed

Lines changed: 84 additions & 8 deletions

File tree

builder/builder.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,12 @@ func (h *HeighlinerBuilder) buildChainNodeDockerImage(
518518

519519
push := buildCfg.ContainerRegistry != "" && !buildCfg.SkipPush
520520

521+
// When final-base is set (e.g. "glibc"), use that stage as the build target (for pre-built glibc binaries).
522+
buildTarget := ""
523+
if dockerfile == DockerfileTypeCosmos && chainConfig.Build.FinalBase != "" {
524+
buildTarget = chainConfig.Build.FinalBase
525+
}
526+
521527
if buildCfg.UseBuildKit {
522528
buildKitOptions := docker.GetDefaultBuildKitOptions()
523529
buildKitOptions.Address = buildCfg.BuildKitAddr
@@ -541,11 +547,11 @@ func (h *HeighlinerBuilder) buildChainNodeDockerImage(
541547
buildKitOptions.Platform = buildCfg.Platform
542548
}
543549
buildKitOptions.NoCache = buildCfg.NoCache
544-
if err := docker.BuildDockerImageWithBuildKit(ctx, reldir, imageTags, push, buildCfg.TarExportPath, buildArgs, buildKitOptions); err != nil {
550+
if err := docker.BuildDockerImageWithBuildKit(ctx, reldir, imageTags, push, buildCfg.TarExportPath, buildArgs, buildKitOptions, buildTarget); err != nil {
545551
return err
546552
}
547553
} else {
548-
if err := docker.BuildDockerImage(ctx, dfilepath, imageTags, push, buildArgs, buildCfg.NoCache); err != nil {
554+
if err := docker.BuildDockerImage(ctx, dfilepath, imageTags, push, buildArgs, buildCfg.NoCache, buildTarget); err != nil {
549555
return err
550556
}
551557
}

builder/go_versions.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const (
1616
Go122Version = "1.22.7"
1717
Go123Version = "1.23.4"
1818
Go124Version = "1.24.1"
19+
Go125Version = "1.25.7"
1920
// ADD NEW GO VERSION [1] - latest patch release for each major/minor
2021

2122
// When updating alpine image, ensure all golang build image combinations below exist
@@ -33,10 +34,10 @@ var (
3334
Go122Image = GolangAlpineImage(Go122Version, LatestAlpineImageVersion)
3435
Go123Image = GolangAlpineImage(Go123Version, LatestAlpineImageVersion)
3536
Go124Image = GolangAlpineImage(Go124Version, LatestAlpineImageVersion)
36-
37+
Go125Image = GolangAlpineImage(Go125Version, LatestAlpineImageVersion)
3738
// ADD NEW GO VERSION [3] - update GoDefaultVersion and GoDefaultImage to latest
38-
GoDefaultVersion = Go123Version
39-
GoDefaultImage = Go123Image // default image for cosmos go builds if go.mod parse fails
39+
GoDefaultVersion = Go125Version
40+
GoDefaultImage = Go125Image // default image for cosmos go builds if go.mod parse fails
4041
)
4142

4243
func GolangAlpineImage(goVersion, alpineVersion string) string {
@@ -57,6 +58,7 @@ var GoImageForVersion = map[string]GoVersion{
5758
"1.22": GoVersion{Version: Go122Version, Image: Go122Image},
5859
"1.23": GoVersion{Version: Go123Version, Image: Go123Image},
5960
"1.24": GoVersion{Version: Go124Version, Image: Go124Image},
61+
"1.25": GoVersion{Version: Go125Version, Image: Go125Image},
6062
// ADD NEW GO VERSION [4]
6163
}
6264

builder/go_versions_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ func TestGoVersions(t *testing.T) {
3535
goVer = builder.GetImageAndVersionForGoVersion("1.19.10", "")
3636
require.Equal(t, "1.19.10-alpine"+builder.LatestAlpineImageVersion, goVer.Image)
3737
require.Equal(t, "1.19.10", goVer.Version)
38+
39+
goVer = builder.GetImageAndVersionForGoVersion("1.25.7", "")
40+
require.Equal(t, "1.25.7-alpine"+builder.LatestAlpineImageVersion, goVer.Image)
41+
require.Equal(t, "1.25.7", goVer.Version)
3842
}

builder/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type ChainNodeConfig struct {
3131
Dockerfile DockerfileType `yaml:"dockerfile"`
3232
BuildTarget string `yaml:"build-target"`
3333
FinalImage string `yaml:"final-image"`
34+
FinalBase string `yaml:"final-base"` // e.g. "glibc" for pre-built glibc binaries (uses debian final stage)
3435
BuildDir string `yaml:"build-dir"`
3536
Binaries []string `yaml:"binaries"`
3637
Libraries []string `yaml:"libraries"`

chains/celestia.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
github-organization: celestiaorg
33
github-repo: celestia-app
44
dockerfile: cosmos
5+
# Pre-built release binary is linked against glibc 2.38+ (__isoc23_*); use glibc final stage instead of Alpine.
6+
final-base: glibc
57
pre-build: |
68
wget https://github.com/celestiaorg/celestia-app/releases/download/v7.0.2-mocha/celestia-app_Linux_x86_64.tar.gz
79
tar -xzf celestia-app_Linux_x86_64.tar.gz

docker/buildkit.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func BuildDockerImageWithBuildKit(
6060
tarExport string,
6161
args map[string]string,
6262
buildKitOptions BuildKitOptions,
63+
target string,
6364
) error {
6465
c, err := client.New(ctx, buildKitOptions.Address)
6566
if err != nil {
@@ -108,6 +109,9 @@ func BuildDockerImageWithBuildKit(
108109
opts := map[string]string{
109110
"platform": buildKitOptions.Platform,
110111
}
112+
if target != "" {
113+
opts["target"] = target
114+
}
111115
for arg, value := range args {
112116
opts[fmt.Sprintf("build-arg:%s", arg)] = value
113117
}

docker/docker.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type DockerImageBuildLog struct {
3030
ErrorDetail *DockerImageBuildErrorDetail `json:"errorDetail"`
3131
}
3232

33-
func BuildDockerImage(ctx context.Context, dockerfile string, tags []string, push bool, args map[string]string, noCache bool) error {
33+
func BuildDockerImage(ctx context.Context, dockerfile string, tags []string, push bool, args map[string]string, noCache bool, target string) error {
3434
dockerClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
3535
if err != nil {
3636
return err
@@ -51,6 +51,9 @@ func BuildDockerImage(ctx context.Context, dockerfile string, tags []string, pus
5151
Remove: true,
5252
BuildArgs: buildArgs,
5353
}
54+
if target != "" {
55+
opts.Target = target
56+
}
5457

5558
tar, err := archive.TarWithOptions("./", &archive.TarOptions{})
5659
if err != nil {

dockerfile/cosmos/Dockerfile

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ FROM ghcr.io/p2p-org/cosmos-heighliner:infra-toolkit-v0.1.6 AS infra-toolkit
147147
# Use ln and rm from full featured busybox for assembling final image
148148
FROM busybox:1.34.1-musl AS busybox-full
149149

150-
# Build final image from scratch
151-
FROM apline:3
150+
# Build final image from scratch (Alpine/musl - for binaries built in this image)
151+
FROM alpine:3
152152

153153
LABEL org.opencontainers.image.source="https://github.com/p2p-org/cosmos-heighliner"
154154

@@ -221,3 +221,30 @@ COPY --from=build-env /root/lib /lib
221221

222222
WORKDIR /home/p2p
223223
# USER p2p
224+
225+
# Optional target for pre-built glibc binaries (e.g. Celestia release binaries that need __isoc23_* from glibc 2.38+).
226+
# Use: docker build --target glibc ... or heighliner with final-base: glibc in chain config.
227+
# Single COPY from /root to avoid BuildKit multi-platform "layer does not exist" on separate dir_abs copies.
228+
FROM debian:trixie-slim AS glibc
229+
230+
LABEL org.opencontainers.image.source="https://github.com/p2p-org/cosmos-heighliner"
231+
232+
COPY --from=build-env /root /root
233+
234+
RUN set -eux; \
235+
cp -a /root/bin/. /bin/ 2>/dev/null || true; \
236+
rm -rf /root/bin; \
237+
if [ -d /root/lib ] && [ -n "$(ls -A /root/lib 2>/dev/null)" ]; then cp -a /root/lib/. /lib/; fi; \
238+
rm -rf /root/lib; \
239+
if [ -s /root/dir_abs.list ]; then \
240+
i=0; while read -r DIR; do \
241+
[ -z "$DIR" ] && continue; \
242+
PLACEDIR="$(dirname "$DIR")"; \
243+
mkdir -p "$PLACEDIR"; \
244+
mv "/root/dir_abs/$i" "$DIR"; \
245+
i=$((i+1)); \
246+
done < /root/dir_abs.list; \
247+
fi; \
248+
rm -rf /root/dir_abs /root/dir_abs.list
249+
250+
WORKDIR /home/p2p

dockerfile/cosmos/native.Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,30 @@ RUN apk update && \
202202

203203
WORKDIR /home/p2p
204204
# USER p2p
205+
206+
# Optional target for pre-built glibc binaries (e.g. Celestia release binaries that need __isoc23_* from glibc 2.38+).
207+
# Use: docker build --target glibc ... or heighliner with final-base: glibc in chain config.
208+
# Single COPY from /root to avoid BuildKit multi-platform "layer does not exist" on separate dir_abs copies.
209+
FROM debian:trixie-slim AS glibc
210+
211+
LABEL org.opencontainers.image.source="https://github.com/p2p-org/cosmos-heighliner"
212+
213+
COPY --from=build-env /root /root
214+
215+
RUN set -eux; \
216+
cp -a /root/bin/. /bin/ 2>/dev/null || true; \
217+
rm -rf /root/bin; \
218+
if [ -d /root/lib ] && [ -n "$(ls -A /root/lib 2>/dev/null)" ]; then cp -a /root/lib/. /lib/; fi; \
219+
rm -rf /root/lib; \
220+
if [ -s /root/dir_abs.list ]; then \
221+
i=0; while read -r DIR; do \
222+
[ -z "$DIR" ] && continue; \
223+
PLACEDIR="$(dirname "$DIR")"; \
224+
mkdir -p "$PLACEDIR"; \
225+
mv "/root/dir_abs/$i" "$DIR"; \
226+
i=$((i+1)); \
227+
done < /root/dir_abs.list; \
228+
fi; \
229+
rm -rf /root/dir_abs /root/dir_abs.list
230+
231+
WORKDIR /home/p2p

0 commit comments

Comments
 (0)