Skip to content

Commit

Permalink
Add support for Cloud Native Buildpacks pack CLI
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <[email protected]>
  • Loading branch information
dgageot committed Oct 5, 2019
1 parent 3a7b932 commit 5a89036
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pack/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM busybox
ENV PACK_VERSION=v0.4.1
RUN wget -O- https://github.com/buildpack/pack/releases/download/${PACK_VERSION}/pack-${PACK_VERSION}-linux.tgz | tar zx

FROM gcr.io/distroless/base
ENTRYPOINT ["/pack"]
COPY --from=0 /pack /
19 changes: 19 additions & 0 deletions pack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Pack

[pack](https://github.com/buildpack/pack) is the CLI for building apps using [Cloud Native Buildpacks](https://buildpacks.io).

This build step invokes `pack` commands in [Google Cloud Build](cloud.google.com/cloud-build/).

Arguments passed to this builder will be passed to `pack` directly, allowing
callers to run [any pack
command](https://buildpacks.io/docs/using-pack/).

## Usage:

To build a Docker image from sources:

```
steps:
- name: gcr.io/$PROJECT_ID/pack
args: ["build", "--builder", "heroku/buildpacks:18", "gcr.io/$PROJECT_ID/sample:tag"]
```
11 changes: 11 additions & 0 deletions pack/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# In this directory, run the following command to build this builder.
# $ gcloud builds submit . --config=cloudbuild.yaml

steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--tag=gcr.io/${PROJECT_ID}/pack', '.']
- name: 'gcr.io/${PROJECT_ID}/pack'
args: ['--help']

images: ['gcr.io/${PROJECT_ID}/pack']
tags: ['cloud-builders-community']
10 changes: 10 additions & 0 deletions pack/example/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
steps:
- name: 'gcr.io/$PROJECT_ID/pack'
args:
- build
- --builder
- heroku/buildpacks:18
- gcr.io/$PROJECT_ID/pack-sample

images:
- gcr.io/$PROJECT_ID/pack-sample
3 changes: 3 additions & 0 deletions pack/example/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/GoogleCloudPlatform/cloud-builders-community/pack/sample

go 1.13
18 changes: 18 additions & 0 deletions pack/example/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"fmt"
"log"
"net/http"
)

func main() {
http.HandleFunc("/", hello)

log.Println("Listening on port 8080")
http.ListenAndServe(":8080", nil)
}

func hello(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World!")
}

0 comments on commit 5a89036

Please sign in to comment.