Skip to content

Commit

Permalink
Merge pull request #7 from railwayapp/j/add-railway-config-buildpack
Browse files Browse the repository at this point in the history
Add railwayapp/node-config buildpack
  • Loading branch information
coffee-cup authored Aug 28, 2021
2 parents 82aec7d + 73ef146 commit b0218e0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
12 changes: 12 additions & 0 deletions buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ api = "0.5"
id = "paketo-buildpacks/node-engine"
version = "0.6.2"

[[order.group]]
id = "railwayapp/node-config"
version = "0.0.1"

[[order.group]]
id = "paketo-buildpacks/yarn"
version = "0.4.0"
Expand Down Expand Up @@ -67,6 +71,10 @@ api = "0.5"
id = "paketo-buildpacks/node-engine"
version = "0.6.2"

[[order.group]]
id = "railwayapp/node-config"
version = "0.0.1"

[[order.group]]
id = "paketo-buildpacks/npm-install"
version = "0.4.0"
Expand Down Expand Up @@ -111,6 +119,10 @@ api = "0.5"
id = "paketo-buildpacks/node-engine"
version = "0.6.2"

[[order.group]]
id = "railwayapp/node-config"
version = "0.0.1"

[[order.group]]
id = "paketo-buildpacks/node-module-bom"
optional = true
Expand Down
8 changes: 5 additions & 3 deletions integration/node_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func testNodeStart(t *testing.T, context spec.G, it spec.S) {
Execute(name, source)
Expect(err).NotTo(HaveOccurred())

Expect(logs).To(ContainLines(ContainSubstring("Railway Node Config Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Start Buildpack")))
Expect(logs).NotTo(ContainLines(ContainSubstring("Procfile Buildpack")))
Expand Down Expand Up @@ -106,14 +107,15 @@ func testNodeStart(t *testing.T, context spec.G, it spec.S) {
Execute(name, source)
Expect(err).NotTo(HaveOccurred())

Expect(logs).To(ContainLines(ContainSubstring("Railway Node Config Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Start Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Procfile Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("web: node server.js")))
Expect(logs).To(ContainLines(ContainSubstring("Environment Variables Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Image Labels Buildpack")))

Expect(image.Buildpacks[4].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Buildpacks[5].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Labels["some-label"]).To(Equal("some-value"))

container, err = docker.Container.Run.
Expand Down Expand Up @@ -156,15 +158,14 @@ func testNodeStart(t *testing.T, context spec.G, it spec.S) {
Execute(name, source)
Expect(err).NotTo(HaveOccurred())

Expect(logs).To(ContainLines(ContainSubstring("Railway Node Config Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Module Bill of Materials Generator Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Start Buildpack")))
Expect(logs).NotTo(ContainLines(ContainSubstring("Procfile Buildpack")))
Expect(logs).NotTo(ContainLines(ContainSubstring("Environment Variables Buildpack")))
Expect(logs).NotTo(ContainLines(ContainSubstring("Image Labels Buildpack")))

Expect(image.Buildpacks[2].Key).To(Equal("paketo-buildpacks/node-module-bom"))

container, err = docker.Container.Run.
WithEnv(map[string]string{"PORT": "8080"}).
WithPublish("8080").
Expand Down Expand Up @@ -226,6 +227,7 @@ func testNodeStart(t *testing.T, context spec.G, it spec.S) {
Execute(name, filepath.Join(source, "node_server"))
Expect(err).NotTo(HaveOccurred())

Expect(logs).To(ContainLines(ContainSubstring("Railway Node Config Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("CA Certificates Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Start Buildpack")))
Expand Down
9 changes: 4 additions & 5 deletions integration/npm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func testNPM(t *testing.T, context spec.G, it spec.S) {
Execute(name, source)
Expect(err).NotTo(HaveOccurred())

Expect(logs).To(ContainLines(ContainSubstring("Railway Node Config Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("NPM Install Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Module Bill of Materials Generator Buildpack")))
Expand All @@ -73,8 +74,6 @@ func testNPM(t *testing.T, context spec.G, it spec.S) {
Expect(logs).NotTo(ContainLines(ContainSubstring("Environment Variables Buildpack")))
Expect(logs).NotTo(ContainLines(ContainSubstring("Image Labels Buildpack")))

Expect(image.Buildpacks[3].Key).To(Equal("paketo-buildpacks/node-module-bom"))

container, err = docker.Container.Run.
WithEnv(map[string]string{"PORT": "8080"}).
WithPublish("8080").
Expand Down Expand Up @@ -115,6 +114,7 @@ func testNPM(t *testing.T, context spec.G, it spec.S) {
Execute(name, source)
Expect(err).NotTo(HaveOccurred())

Expect(logs).To(ContainLines(ContainSubstring("Railway Node Config Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("NPM Install Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Module Bill of Materials Generator Buildpack")))
Expand All @@ -125,9 +125,8 @@ func testNPM(t *testing.T, context spec.G, it spec.S) {
Expect(logs).To(ContainLines(ContainSubstring("Image Labels Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Run Script")))

Expect(image.Buildpacks[7].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Buildpacks[8].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Labels["some-label"]).To(Equal("some-value"))
Expect(image.Buildpacks[3].Key).To(Equal("paketo-buildpacks/node-module-bom"))

container, err = docker.Container.Run.
WithEnv(map[string]string{"PORT": "8080"}).
Expand Down Expand Up @@ -189,12 +188,12 @@ func testNPM(t *testing.T, context spec.G, it spec.S) {
Execute(name, filepath.Join(source, "npm_server"))
Expect(err).NotTo(HaveOccurred())

Expect(logs).To(ContainLines(ContainSubstring("Railway Node Config Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("CA Certificates Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("NPM Install Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Module Bill of Materials Generator Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("NPM Start Buildpack")))
Expect(image.Buildpacks[3].Key).To(Equal("paketo-buildpacks/node-module-bom"))

// NOTE: NODE_OPTIONS="--use-openssl-ca" is NOT required since the node binary is compiled with `--openssl-use-def-ca-store`
container, err = docker.Container.Run.
Expand Down
9 changes: 3 additions & 6 deletions integration/yarn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func testYarn(t *testing.T, context spec.G, it spec.S) {
Expect(err).NotTo(HaveOccurred())

Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Railway Node Config Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Yarn Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Yarn Install Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Module Bill of Materials Generator Buildpack")))
Expand All @@ -73,8 +74,6 @@ func testYarn(t *testing.T, context spec.G, it spec.S) {
Expect(logs).NotTo(ContainLines(ContainSubstring("Environment Variables Buildpack")))
Expect(logs).NotTo(ContainLines(ContainSubstring("Image Labels Buildpack")))

Expect(image.Buildpacks[4].Key).To(Equal("paketo-buildpacks/node-module-bom"))

container, err = docker.Container.Run.
WithEnv(map[string]string{"PORT": "8080"}).
WithPublish("8080").
Expand Down Expand Up @@ -108,6 +107,7 @@ func testYarn(t *testing.T, context spec.G, it spec.S) {
Expect(err).NotTo(HaveOccurred())

Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Railway Node Config Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Yarn Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Yarn Install Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Module Bill of Materials Generator Buildpack")))
Expand All @@ -118,9 +118,8 @@ func testYarn(t *testing.T, context spec.G, it spec.S) {
Expect(logs).To(ContainLines(ContainSubstring("Image Labels Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Run Script")))

Expect(image.Buildpacks[8].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Buildpacks[9].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Labels["some-label"]).To(Equal("some-value"))
Expect(image.Buildpacks[4].Key).To(Equal("paketo-buildpacks/node-module-bom"))

container, err = docker.Container.Run.
WithEnv(map[string]string{"PORT": "8080"}).
Expand Down Expand Up @@ -188,8 +187,6 @@ func testYarn(t *testing.T, context spec.G, it spec.S) {
Expect(logs).To(ContainLines(ContainSubstring("Node Module Bill of Materials Generator Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Yarn Start Buildpack")))

Expect(image.Buildpacks[4].Key).To(Equal("paketo-buildpacks/node-module-bom"))

// NOTE: NODE_OPTIONS="--use-openssl-ca" is NOT required since the node binary is compiled with `--openssl-use-def-ca-store`
container, err = docker.Container.Run.
WithPublish("8080").
Expand Down
3 changes: 3 additions & 0 deletions package.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@

[[dependencies]]
uri = "docker://gcr.io/paketo-buildpacks/node-module-bom:0.1.0"

[[dependencies]]
uri = "docker://ghcr.io/railwayapp/node-config:0.0.1"

0 comments on commit b0218e0

Please sign in to comment.