Skip to content

Commit f0eca79

Browse files
authored
Merge pull request #12 from apppackio/latest-pack
Switch pack version based on builder
2 parents 9a75db4 + b221ae3 commit f0eca79

File tree

4 files changed

+89
-10
lines changed

4 files changed

+89
-10
lines changed

.github/workflows/build.yml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,65 @@ jobs:
100100
cat apppack.toml
101101
test "$(python -c 'import tomllib; print(tomllib.load(open("apppack.toml", "rb"))["services"]["web"]["command"])')" = "bash -c 'gunicorn --access-logfile - --bind 0.0.0.0:\$PORT --forwarded-allow-ips '\"'\"'*'\"'\"' app:app'"
102102
103+
integration-heroku24:
104+
runs-on: ubuntu-latest
105+
needs: [test, build-image]
106+
permissions:
107+
id-token: write
108+
contents: read
109+
packages: read
110+
steps:
111+
- name: Login to GitHub Container Registry
112+
uses: docker/login-action@v2
113+
with:
114+
registry: ghcr.io
115+
username: ${{ github.actor }}
116+
password: ${{ secrets.GITHUB_TOKEN }}
117+
- name: Pull image
118+
run: docker pull ${{ needs.build-image.outputs.image }}
119+
- name: configure aws credentials
120+
uses: aws-actions/configure-aws-credentials@v4
121+
with:
122+
role-to-assume: arn:aws:iam::891426818781:role/github-actions-integration-tests
123+
aws-region: us-east-1
124+
- name: Checkout sample repo
125+
run: git clone --branch buildpacks-24 https://github.com/apppackio/apppack-demo-python.git
126+
- name: Run integration tests
127+
working-directory: ./apppack-demo-python
128+
run: |
129+
cat <<EOF > .envfile
130+
APPNAME=gh-integration
131+
CODEBUILD_BUILD_ID=demo-python:${{ github.run_id }}
132+
CODEBUILD_SOURCE_VERSION=${{ github.sha }}
133+
DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}
134+
DOCKERHUB_ACCESS_TOKEN=${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
135+
DOCKER_REPO=891426818781.dkr.ecr.us-east-1.amazonaws.com/github-integration-test
136+
ARTIFACT_BUCKET=integration-test-buildartifacts
137+
AWS_REGION
138+
AWS_ACCESS_KEY_ID
139+
AWS_SECRET_ACCESS_KEY
140+
AWS_SESSION_TOKEN
141+
EOF
142+
143+
docker run \
144+
--rm \
145+
--privileged \
146+
--env-file .envfile \
147+
--volume /var/run/docker.sock:/var/run/docker.sock \
148+
--volume "$(pwd):/app" \
149+
--workdir /app \
150+
${{ needs.build-image.outputs.image }} \
151+
/bin/sh -c "set -x; git config --global --add safe.directory /app && apppack-builder prebuild; apppack-builder build; apppack-builder postbuild"
152+
- uses: actions/setup-python@v4
153+
with:
154+
python-version: "3.11"
155+
- name: Verify apppack.toml
156+
working-directory: ./apppack-demo-python
157+
run: |
158+
set -ex
159+
cat apppack.toml
160+
test "$(python -c 'import tomllib; print(tomllib.load(open("apppack.toml", "rb"))["services"]["web"]["command"])')" = "bash -c 'gunicorn --access-logfile - --bind 0.0.0.0:\$PORT --forwarded-allow-ips '\"'\"'*'\"'\"' app:app'"
161+
103162
integration-appjson:
104163
runs-on: ubuntu-latest
105164
needs: [test, build-image]
@@ -281,7 +340,14 @@ jobs:
281340
runs-on: ubuntu-latest
282341
# Only run this job if the current commit is tagged with a version
283342
if: startswith(github.ref, 'refs/tags/v')
284-
needs: [test, build-image, integration, integration-docker, integration-appjson, integration-heroku20]
343+
needs:
344+
- test
345+
- build-image
346+
- integration
347+
- integration-docker
348+
- integration-appjson
349+
- integration-heroku20
350+
- integration-heroku24
285351
permissions:
286352
id-token: write
287353
contents: read

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/appjson.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ var IncludedBuildpacks = map[string][]string{
5454
},
5555
"heroku-22": {
5656
// $ pack builder inspect heroku/builder:22 -o json | jq '.remote_info.buildpacks[].id'
57+
"heroku/deb-packages",
58+
"heroku/dotnet",
5759
"heroku/go",
5860
"heroku/gradle",
5961
"heroku/java",
@@ -64,7 +66,7 @@ var IncludedBuildpacks = map[string][]string{
6466
"heroku/nodejs-engine",
6567
"heroku/nodejs-npm-engine",
6668
"heroku/nodejs-npm-install",
67-
"heroku/nodejs-pnpm-engine",
69+
"heroku/nodejs-pnpm-engine",
6870
"heroku/nodejs-pnpm-install",
6971
"heroku/nodejs-yarn",
7072
"heroku/php",

builder/build/build.go

Lines changed: 9 additions & 3 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+
packBinary := "pack"
142+
if builder == "heroku/buildpacks:20" {
143+
// use legacy pack for heroku/buildpacks:20
144+
packBinary = "pack-legacy"
145+
b.Log().Debug().Msg(fmt.Sprintf("using legacy pack version for %s", builder))
146+
}
147+
cmd := exec.Command(packBinary, "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",
@@ -158,7 +164,7 @@ func (b *Build) buildWithPack(config *containers.BuildConfig) error {
158164
}
159165
packArgs = append(packArgs, config.Image)
160166
b.Log().Debug().Str("builder", builder).Str("buildpacks", buildpacks).Msg("building image")
161-
cmd = exec.Command("pack", packArgs...)
167+
cmd = exec.Command(packBinary, packArgs...)
162168
out := io.MultiWriter(os.Stdout, config.LogFile)
163169
cmd.Stdout = out
164170
cmd.Stderr = out

0 commit comments

Comments
 (0)