Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 67 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,65 @@ jobs:
cat apppack.toml
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'"

integration-heroku24:
runs-on: ubuntu-latest
needs: [test, build-image]
permissions:
id-token: write
contents: read
packages: read
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull image
run: docker pull ${{ needs.build-image.outputs.image }}
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::891426818781:role/github-actions-integration-tests
aws-region: us-east-1
- name: Checkout sample repo
run: git clone --branch buildpacks-24 https://github.com/apppackio/apppack-demo-python.git
- name: Run integration tests
working-directory: ./apppack-demo-python
run: |
cat <<EOF > .envfile
APPNAME=gh-integration
CODEBUILD_BUILD_ID=demo-python:${{ github.run_id }}
CODEBUILD_SOURCE_VERSION=${{ github.sha }}
DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_ACCESS_TOKEN=${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
DOCKER_REPO=891426818781.dkr.ecr.us-east-1.amazonaws.com/github-integration-test
ARTIFACT_BUCKET=integration-test-buildartifacts
AWS_REGION
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN
EOF

docker run \
--rm \
--privileged \
--env-file .envfile \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$(pwd):/app" \
--workdir /app \
${{ needs.build-image.outputs.image }} \
/bin/sh -c "set -x; git config --global --add safe.directory /app && apppack-builder prebuild; apppack-builder build; apppack-builder postbuild"
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Verify apppack.toml
working-directory: ./apppack-demo-python
run: |
set -ex
cat apppack.toml
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'"

integration-appjson:
runs-on: ubuntu-latest
needs: [test, build-image]
Expand Down Expand Up @@ -281,7 +340,14 @@ jobs:
runs-on: ubuntu-latest
# Only run this job if the current commit is tagged with a version
if: startswith(github.ref, 'refs/tags/v')
needs: [test, build-image, integration, integration-docker, integration-appjson, integration-heroku20]
needs:
- test
- build-image
- integration
- integration-docker
- integration-appjson
- integration-heroku20
- integration-heroku24
permissions:
id-token: write
contents: read
Expand Down
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
FROM golang:1.22-alpine as builder
FROM golang:1.22-alpine AS builder
RUN apk add --no-cache curl
# last pack version that supports heroku/buildpacks:20 builder
ENV PACK_VER=0.31.0
# Install current `pack` and v0.31.0, the last pack version that supports heroku/buildpacks:20 builder
ENV PACK_VER=0.38.0
RUN set -ex && \
cd /tmp && \
mkdir -p /tmp/legacy-pack /tmp/current-pack && \
cd /tmp/legacy-pack && \
curl -sLO "https://github.com/buildpacks/pack/releases/download/v0.31.0/pack-v0.31.0-linux.tgz" && \
tar xvzf "pack-v0.31.0-linux.tgz" && \
cd /tmp/current-pack && \
curl -sLO "https://github.com/buildpacks/pack/releases/download/v$PACK_VER/pack-v$PACK_VER-linux.tgz" && \
tar xvzf "pack-v$PACK_VER-linux.tgz"

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

FROM docker:26-dind
COPY --from=builder /tmp/pack /usr/local/bin/pack
COPY --from=builder /tmp/legacy-pack/pack /usr/local/bin/pack-legacy
COPY --from=builder /tmp/current-pack/pack /usr/local/bin/pack
RUN apk add --no-cache git
COPY --from=builder /go/bin/apppack-builder /usr/local/bin/apppack-builder
4 changes: 3 additions & 1 deletion builder/build/appjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ var IncludedBuildpacks = map[string][]string{
},
"heroku-22": {
// $ pack builder inspect heroku/builder:22 -o json | jq '.remote_info.buildpacks[].id'
"heroku/deb-packages",
"heroku/dotnet",
"heroku/go",
"heroku/gradle",
"heroku/java",
Expand All @@ -64,7 +66,7 @@ var IncludedBuildpacks = map[string][]string{
"heroku/nodejs-engine",
"heroku/nodejs-npm-engine",
"heroku/nodejs-npm-install",
"heroku/nodejs-pnpm-engine",
"heroku/nodejs-pnpm-engine",
"heroku/nodejs-pnpm-install",
"heroku/nodejs-yarn",
"heroku/php",
Expand Down
12 changes: 9 additions & 3 deletions builder/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,17 @@ func (b *Build) buildWithDocker(config *containers.BuildConfig) error {

func (b *Build) buildWithPack(config *containers.BuildConfig) error {
b.Log().Debug().Msg("pack config registry-mirrors")
cmd := exec.Command("pack", "config", "registry-mirrors", "add", "index.docker.io", "--mirror", DockerHubMirror)
builder := b.BuildpackBuilders()[0]
packBinary := "pack"
if builder == "heroku/buildpacks:20" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ipmb Hi! Do you have metrics as to what proportion of your users are using the legacy heroku/buildpacks:* images (vs the heroku/builder:* images)? We had been planning on making the heroku/buildpacks repo private at some point to prevent people unknowingly using an insecure image (it hasn't had security updates since May 2024), but wouldn't want that to cause too much disruption to you/your users.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @edmorley! This is the blocker for moving our last user over to CNB heroku/buildpacks-deb-packages#110

// use legacy pack for heroku/buildpacks:20
packBinary = "pack-legacy"
b.Log().Debug().Msg(fmt.Sprintf("using legacy pack version for %s", builder))
}
cmd := exec.Command(packBinary, "config", "registry-mirrors", "add", "index.docker.io", "--mirror", DockerHubMirror)
if err := cmd.Run(); err != nil {
return err
}
builder := b.BuildpackBuilders()[0]
buildpacks := strings.Join(b.AppJSON.GetBuildpacks(), ",")
packArgs := []string{
"build",
Expand All @@ -158,7 +164,7 @@ func (b *Build) buildWithPack(config *containers.BuildConfig) error {
}
packArgs = append(packArgs, config.Image)
b.Log().Debug().Str("builder", builder).Str("buildpacks", buildpacks).Msg("building image")
cmd = exec.Command("pack", packArgs...)
cmd = exec.Command(packBinary, packArgs...)
out := io.MultiWriter(os.Stdout, config.LogFile)
cmd.Stdout = out
cmd.Stderr = out
Expand Down