Skip to content

Commit

Permalink
add Node.js to builder (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: Forest Eckhardt <[email protected]>
  • Loading branch information
sophiewigmore and ForestEckhardt authored Aug 4, 2022
1 parent 74e8b9c commit e49f2e5
Show file tree
Hide file tree
Showing 9 changed files with 1,156 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
This builder uses the [Paketo Jammy Full
Stack](https://github.com/paketo-buildpacks/jammy-full-stack) (Ubuntu Jammy
Jellyfish build and run images) with buildpacks for Java,
Java Native Image, Go, .NET, and Procfile.
Java Native Image, Go, .NET, Node.js, and Procfile.

To see which versions of build and run images, buildpacks, and the lifecycle
that are contained within a given builder version, see the
Expand Down
10 changes: 10 additions & 0 deletions builder.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ description = "Ubuntu 22.04 Jammy Jellyfish full image with buildpacks for Java,
uri = "docker://gcr.io/paketo-buildpacks/java:6.33.0"
version = "6.33.0"

[[buildpacks]]
uri = "docker://gcr.io/paketo-buildpacks/nodejs:0.22.0"
version = "0.22.0"

[[buildpacks]]
uri = "docker://gcr.io/paketo-buildpacks/procfile:5.2.1"
version = "5.2.1"
Expand Down Expand Up @@ -47,6 +51,12 @@ description = "Ubuntu 22.04 Jammy Jellyfish full image with buildpacks for Java,
id = "paketo-buildpacks/java"
version = "6.33.0"

[[order]]

[[order.group]]
id = "paketo-buildpacks/nodejs"
version = "0.22.0"

[[order]]

[[order.group]]
Expand Down
1 change: 1 addition & 0 deletions smoke/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestSmoke(t *testing.T) {
suite("Go", testGo)
suite("Java Native Image", testJavaNativeImage)
suite("Java", testJava)
suite("Node.js", testNodejs)
suite("Procfile", testProcfile)
suite.Run(t)
}
77 changes: 77 additions & 0 deletions smoke/nodejs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package smoke_test

import (
"fmt"
"os"
"path/filepath"
"testing"

"github.com/paketo-buildpacks/occam"
"github.com/sclevine/spec"

. "github.com/onsi/gomega"
. "github.com/paketo-buildpacks/occam/matchers"
)

func testNodejs(t *testing.T, context spec.G, it spec.S) {
var (
Expect = NewWithT(t).Expect
Eventually = NewWithT(t).Eventually

pack occam.Pack
docker occam.Docker
)

it.Before(func() {
pack = occam.NewPack().WithVerbose().WithNoColor()
docker = occam.NewDocker()
})

context("detects a Nodejs app", func() {
var (
image occam.Image
container occam.Container

name string
source string
)

it.Before(func() {
var err error
name, err = occam.RandomName()
Expect(err).NotTo(HaveOccurred())
})

it.After(func() {
Expect(docker.Container.Remove.Execute(container.ID)).To(Succeed())
Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed())
Expect(docker.Image.Remove.Execute(image.ID)).To(Succeed())
Expect(os.RemoveAll(source)).To(Succeed())
})

it("builds successfully", func() {
var err error
source, err = occam.Source(filepath.Join("testdata", "nodejs"))
Expect(err).NotTo(HaveOccurred())

var logs fmt.Stringer
image, logs, err = pack.Build.
WithPullPolicy("never").
WithBuilder(Builder).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), logs.String)

container, err = docker.Container.Run.
WithEnv(map[string]string{"PORT": "8080"}).
WithPublish("8080").
Execute(image.ID)
Expect(err).NotTo(HaveOccurred())

Eventually(container).Should(BeAvailable())

Expect(logs).To(ContainLines(ContainSubstring("Paketo Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Paketo NPM Install Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Paketo NPM Start Buildpack")))
})
})
}
1 change: 1 addition & 0 deletions smoke/testdata/nodejs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
13 changes: 13 additions & 0 deletions smoke/testdata/nodejs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Node.js Sample App using NPM

## Building

`pack build npm-sample --buildpack gcr.io/paketo-buildpacks/nodejs`

## Running

`docker run --interactive --tty --publish 8080:8080 npm-sample`

## Viewing

`curl http://localhost:8080`
Loading

0 comments on commit e49f2e5

Please sign in to comment.