diff --git a/.github/pipeline-descriptor.yml b/.github/pipeline-descriptor.yml new file mode 100644 index 0000000..649d2a8 --- /dev/null +++ b/.github/pipeline-descriptor.yml @@ -0,0 +1,13 @@ +github: + username: ${{ github.actor }} + token: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }} + +package: + repositories: ["ghcr.io/amp-buildpacks/cairo"] + register: false + registry_token: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }} + +docker_credentials: + - registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/pb-update-pipeline.yml b/.github/workflows/pb-update-pipeline.yml new file mode 100644 index 0000000..fc2fe65 --- /dev/null +++ b/.github/workflows/pb-update-pipeline.yml @@ -0,0 +1,87 @@ +name: Update Pipeline +"on": + push: + branches: + - main + paths: + - .github/pipeline-descriptor.yml + schedule: + - cron: 0 5 * * 1-5 + workflow_dispatch: {} +jobs: + update: + name: Update Pipeline + runs-on: + - ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: "1.20" + - name: Install octo + run: | + #!/usr/bin/env bash + + set -euo pipefail + + go install -ldflags="-s -w" github.com/paketo-buildpacks/pipeline-builder/cmd/octo@latest + - uses: actions/checkout@v3 + - name: Update Pipeline + id: pipeline + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [[ -f .github/pipeline-version ]]; then + OLD_VERSION=$(cat .github/pipeline-version) + else + OLD_VERSION="0.0.0" + fi + + rm .github/workflows/pb-*.yml || true + octo --descriptor "${DESCRIPTOR}" + + PAYLOAD=$(gh api /repos/paketo-buildpacks/pipeline-builder/releases/latest) + + NEW_VERSION=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.name') + echo "${NEW_VERSION}" > .github/pipeline-version + + RELEASE_NOTES=$( + gh api \ + -F text="$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.body')" \ + -F mode="gfm" \ + -F context="paketo-buildpacks/pipeline-builder" \ + -X POST /markdown + ) + + git add .github/ + git checkout -- . + + echo "old-version=${OLD_VERSION}" >> "$GITHUB_OUTPUT" + echo "new-version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" + + DELIMITER=$(openssl rand -hex 16) # roughly the same entropy as uuid v4 used in https://github.com/actions/toolkit/blob/b36e70495fbee083eb20f600eafa9091d832577d/packages/core/src/file-command.ts#L28 + printf "release-notes<<%s\n%s\n%s\n" "${DELIMITER}" "${RELEASE_NOTES}" "${DELIMITER}" >> "${GITHUB_OUTPUT}" # see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings + env: + DESCRIPTOR: .github/pipeline-descriptor.yml + GITHUB_TOKEN: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }} + - uses: peter-evans/create-pull-request@v5 + with: + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + body: |- + Bumps pipeline from `${{ steps.pipeline.outputs.old-version }}` to `${{ steps.pipeline.outputs.new-version }}`. + +
+ Release Notes + ${{ steps.pipeline.outputs.release-notes }} +
+ branch: update/pipeline + commit-message: |- + Bump pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }} + + Bumps pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}. + delete-branch: true + labels: semver:patch, type:task + signoff: true + title: Bump pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }} + token: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..88bbcad --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +# Copyright (c) The Amphitheatre Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +bin/ +dependencies/ +package/ +scratch/ diff --git a/README.md b/README.md index d247b60..2849b3a 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,11 @@ enable the building of a Cairo-based application. ## Included Buildpacks -- [`amp-buildpacks/scarb`](https://github.com/amp-buildpacks/scarb)(WIP) -- [`amp-buildpacks/starknet`](https://github.com/amp-buildpacks/starknet)(WIP) + +- [`amp-buildpacks/scarb`](https://github.com/amp-buildpacks/scarb) + +- [`amp-buildpacks/starknet`](https://github.com/amp-buildpacks/starknet) + - [`paketo-buildpacks/procfile`](https://github.com/paketo-buildpacks/procfile) ## tl;dr @@ -35,112 +38,6 @@ Packages](https://github.com/orgs/amp-buildpacks/packages). To use: `pack build -b ghcr.io/amp-buildpacks/cairo` -### A Builder - -In this repo is a sample `example-builder.toml` that you can use to create your -own builder. We do not publish a builder, so if you'd like to use this route you -must first create the builder. - -To create the builder, just run `pack builder create /cairo-builder ---config example-builder.toml`. For example, `pack builder create -amp-buildpacks/cairo-builder --config example-builder.toml`. - -You can then build an app with it using `pack build --builder -/cairo-builder`. - -The builder is configure to use the base build and run images, which is a -reasonable mix of size and functionality. You may change the build and run -images to use the full stack, which has a lot more libraries and tools installed -but is quite a bit larger, or you can use the tiny build and run images which -presents a very small container but doesn't even contain a shell, which can make -debugging difficult. - -To switch, swap the stack that you'd like to use in the builder file. - -Example full stack: - -``` -[stack] - id = "io.buildpacks.stacks.jammy" - build-image = "docker.io/paketobuildpacks/build-jammy-base:latest" - run-image = "docker.io/paketobuildpacks/run-jammy-base:latest" -``` - -Example tiny stack: - -``` -[stack] - id = "io.buildpacks.stacks.jammy.tiny" - build-image = "docker.io/paketobuildpacks/build-jammy-tiny" - run-image = "docker.io/paketobuildpacks/run-jammy-tiny" -``` - -## Tips - -- When building for the Paketo Tiny stack, you must build with the target set to - `x86_64-unknown-linux-musl`. This is because if you build with the glibc - target, you will end up with a dependency for the `libgcc_s.so.1` library that - does not exist on the Paketo Tiny run image. If we target musl instead, you'll - get a binary that is statically compiled against musl and does not have this - requirement, thus it will run on the Tiny stack. - - When you run with the Tiny stack, the buildpacks will detect this and - automatically adjust. This includes installing the additional target to - cross-compile and modifying build commands cross-compile using the musl - target. - -- By default, the Cairo buildpack will install `tini`, which is a very small - process manager that handles the PID1 responsibilities (it's also the same - running `docker run --init`), into your application image. Because your - application will run as PID1, this ensures that your application will properly - handle signals. If you are running your image with Docker, this is what makes - CTRL+C function correctly. If you're running on Kubernetes, this is what makes - graceful termination work correctly. - - It is generally recommended that you keep `tini` installed. It's extremely - low-overhead. That said, if you really, really know what you're doing and your - application is properly handling signals and reaping child processes then you - may set `$BP_CAIRO_TINI_DISABLED=true` and the buildpacks will skip installing - `tini.`. - -- What's the difference between using a builder and using the composite - buildpack (i.e. `ghcr.io/amp-buildpacks/cairo`)? There's not a lot of - difference, so feel free to use which one is more convenient for your use - cases. The composite buildpack is published to Amphitheatre Buildpacks - Packages so it's often easier to get started using it. We are not publishing a - builder image at the moment, so you need to build that on your own. The - builder does offer some additional customization options though. Plus, you can - set a default builder with `pack`, so if you're building many different - applications it can reduce the amount of flags you need to send to `pack - build`. You do not need to use both the builder and composite buildpack. - -- Can I specify multiple processes in my `Procfile`? Yes! To make this work, - just add more lines to `Procfile`. One of the lines needs to be named `web`, - which is the expected name for the default process. Alternatively, you may use - different names but pass the `--default-process` argument to `pack build` to - indicate the default process name in your `Procfile`. It is highly recommended - that you have a default process. See [here for more details on multiple - process - containers](https://buildpacks.io/docs/app-developer-guide/run-an-app/). - -- Can I pass arguments to my application? Yes, you just append them to the end - of your `docker run` command. See [here for an - example](https://buildpacks.io/docs/app-developer-guide/run-an-app/#default-process-type-with-additional-arguments). - -- How do I run a non-default process from my `Procfile`? Pass `--entrypoint - ` to `docker run`. See [here for an - example](https://buildpacks.io/docs/app-developer-guide/run-an-app/#non-default-process-type). - -- How do I launch a shell in my container to debug? There are two ways to do - this. - [First](https://buildpacks.io/docs/app-developer-guide/run-an-app/#user-provided-shell-process), - `docker run --rm --entrypoint launcher -it bash`. The first will - set up the shell with the standard environment, the same as what your - application will get when it launches. - [Second](https://buildpacks.io/docs/app-developer-guide/run-an-app/#no-launcher), - `docker run --rm --entrypoint bash -it `. The second will give you - a blank environment without any buildpack specific environment variables set. - ## Contributing If anything feels off, or if you feel that some functionality is missing, please diff --git a/buildpack.toml b/buildpack.toml index 6c93e16..078a1e3 100644 --- a/buildpack.toml +++ b/buildpack.toml @@ -1,12 +1,26 @@ -api = "0.7" +# Copyright (c) The Amphitheatre Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +api = "0.8" [buildpack] description = "A Cloud Native Buildpack with an order definition suitable for Cairo applications" homepage = "https://github.com/amp-buildpacks/cairo" id = "amp-buildpacks/cairo" - keywords = ["cairo", "composite"] - name = "Cairo Build Pack" - version = "{{.version}}" + keywords = ["Cairo"] + name = "AMP Buildpack for Cairo" + version = "{{ .version }}" [[buildpack.licenses]] type = "Apache-2.0" @@ -17,9 +31,11 @@ api = "0.7" [[order]] + [[order.group]] id = "amp-buildpacks/scarb" - version = "0.1.0" + version = "0.2.0" + [[order.group]] id = "amp-buildpacks/starknet" version = "0.1.0" diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..d106729 --- /dev/null +++ b/config.toml @@ -0,0 +1,7 @@ +[[dependencies]] +repo = "amp-buildpacks/scarb" +version = "0.2.0" + +[[dependencies]] +repo = "amp-buildpacks/starknet" +version = "0.1.0" diff --git a/example-builder.toml b/example-builder.toml deleted file mode 100644 index d3395f7..0000000 --- a/example-builder.toml +++ /dev/null @@ -1,30 +0,0 @@ -description = "A sample Builder for using Cairo related CNBs" - -[[buildpacks]] - id = "amp-buildpacks/scarb" - uri = "docker://ghcr.io/amp-buildpacks/scarb:0.1.0" - - [[buildpacks]] - id = "amp-buildpacks/starknet" - uri = "docker://ghcr.io/amp-buildpacks/starknet:0.1.0" - -[[buildpacks]] - id = "paketo-buildpacks/procfile" - uri = "docker://gcr.io/paketo-buildpacks/procfile:5.6.8" - -[[order]] - - [[order.group]] - id = "amp-buildpacks/scarb" - - [[order.group]] - id = "amp-buildpacks/starknet" - - [[order.group]] - id = "paketo-buildpacks/procfile" - optional = true - -[stack] - build-image = "docker.io/paketobuildpacks/build-jammy-tiny" - id = "io.buildpacks.stacks.jammy.tiny" - run-image = "docker.io/paketobuildpacks/run-jammy-tiny" diff --git a/package.toml b/package.toml index b429318..a5a341d 100644 --- a/package.toml +++ b/package.toml @@ -1,7 +1,18 @@ + [[dependencies]] - uri = "docker://ghcr.io/amp-buildpacks/scarb:0.1.0" + uri = "docker://ghcr.io/amp-buildpacks/scarb:0.2.0" + [[dependencies]] uri = "docker://ghcr.io/amp-buildpacks/starknet:0.1.0" + [[dependencies]] uri = "docker://gcr.io/paketo-buildpacks/procfile:5.6.8" + +[[targets]] + arch = "amd64" + os = "linux" + +[[targets]] + arch = "arm64" + os = "linux"