Skip to content

Commit dfbacc2

Browse files
committed
Use newer pack for all but heroku/buildpacks:20
1 parent 9a75db4 commit dfbacc2

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

Dockerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
FROM golang:1.22-alpine as builder
1+
FROM golang:1.22-alpine AS builder
22
RUN apk add --no-cache curl
3-
# last pack version that supports heroku/buildpacks:20 builder
4-
ENV PACK_VER=0.31.0
3+
# Install current `pack` and v0.31.0, the last pack version that supports heroku/buildpacks:20 builder
4+
ENV PACK_VER=0.38.0
55
RUN set -ex && \
6-
cd /tmp && \
6+
mkdir -p /tmp/legacy-pack /tmp/current-pack && \
7+
cd /tmp/legacy-pack && \
8+
curl -sLO "https://github.com/buildpacks/pack/releases/download/v0.31.0/pack-v0.31.0-linux.tgz" && \
9+
tar xvzf "pack-v0.31.0-linux.tgz" && \
10+
cd /tmp/current-pack && \
711
curl -sLO "https://github.com/buildpacks/pack/releases/download/v$PACK_VER/pack-v$PACK_VER-linux.tgz" && \
812
tar xvzf "pack-v$PACK_VER-linux.tgz"
913

@@ -12,6 +16,7 @@ COPY ./builder .
1216
RUN go build -o /go/bin/apppack-builder main.go
1317

1418
FROM docker:26-dind
15-
COPY --from=builder /tmp/pack /usr/local/bin/pack
19+
COPY --from=builder /tmp/legacy-pack/pack /usr/local/bin/pack-legacy
20+
COPY --from=builder /tmp/current-pack/pack /usr/local/bin/pack
1621
RUN apk add --no-cache git
1722
COPY --from=builder /go/bin/apppack-builder /usr/local/bin/apppack-builder

builder/build/build.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,17 @@ func (b *Build) buildWithDocker(config *containers.BuildConfig) error {
137137

138138
func (b *Build) buildWithPack(config *containers.BuildConfig) error {
139139
b.Log().Debug().Msg("pack config registry-mirrors")
140-
cmd := exec.Command("pack", "config", "registry-mirrors", "add", "index.docker.io", "--mirror", DockerHubMirror)
140+
builder := b.BuildpackBuilders()[0]
141+
cmdName := "pack"
142+
if builder == "heroku/buildpacks:20" {
143+
// use legacy pack for heroku/builder:20
144+
cmdName = "pack-legacy"
145+
b.Log().Debug().Msg("using legacy pack version for heroku/buildpacks:20")
146+
}
147+
cmd := exec.Command(cmdName, "config", "registry-mirrors", "add", "index.docker.io", "--mirror", DockerHubMirror)
141148
if err := cmd.Run(); err != nil {
142149
return err
143150
}
144-
builder := b.BuildpackBuilders()[0]
145151
buildpacks := strings.Join(b.AppJSON.GetBuildpacks(), ",")
146152
packArgs := []string{
147153
"build",

0 commit comments

Comments
 (0)