Skip to content

Commit

Permalink
Adds rails-assets buildpack to group orderings
Browse files Browse the repository at this point in the history
- also includes node-engine, yarn, and yarn-install to support
rails-assets
  • Loading branch information
Ryan Moran authored and sophiewigmore committed Jan 5, 2021
1 parent 8a5043a commit 6bc3980
Show file tree
Hide file tree
Showing 63 changed files with 9,127 additions and 17 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@

The Ruby Paketo Buildpack provides a set of collaborating buildpacks that
enable the building of a Ruby-based application. These buildpacks include:
- [MRI](https://github.com/paketo-community/mri)
- [Bundler](https://github.com/paketo-community/bundler)
- [Bundle Install](https://github.com/paketo-community/bundle-install)
- [Puma](https://github.com/paketo-community/puma/)
- [Thin](https://github.com/paketo-community/thin/)
- [Unicorn](https://github.com/paketo-community/unicorn/)
- [Rackup](https://github.com/paketo-community/rackup/)
- [Passenger](https://github.com/paketo-community/passenger/)
- [Rake](https://github.com/paketo-community/rake)
- [Bundle Install](https://github.com/paketo-buildpacks/bundle-install)
- [Bundler](https://github.com/paketo-buildpacks/bundler)
- [MRI](https://github.com/paketo-buildpacks/mri)
- [Node Engine](https://github.com/paketo-buildpacks/node-engine)
- [Passenger](https://github.com/paketo-buildpacks/passenger)
- [Puma](https://github.com/paketo-buildpacks/puma)
- [Rackup](https://github.com/paketo-buildpacks/rackup)
- [Rails Assets](https://github.com/paketo-buildpacks/rails-assets)
- [Rake](https://github.com/paketo-buildpacks/rake)
- [Thin](https://github.com/paketo-buildpacks/thin)
- [Unicorn](https://github.com/paketo-buildpacks/unicorn)
- [Yarn Install](https://github.com/paketo-buildpacks/yarn-install)
- [Yarn](https://github.com/paketo-buildpacks/yarn)

The buildpack supports building simple Ruby applications or applications which
utilize [Bundler](https://bundler.io/) for managing their dependencies. Usage
Expand Down
100 changes: 100 additions & 0 deletions buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ api = "0.2"
id = "paketo-buildpacks/bundle-install"
version = "0.1.2"

[[order.group]]
id = "paketo-buildpacks/node-engine"
version = "0.1.4"
optional = true

[[order.group]]
id = "paketo-buildpacks/yarn"
version = "0.1.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/yarn-install"
version = "0.2.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/rails-assets"
version = "0.0.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/puma"
version = "0.0.53"
Expand All @@ -45,6 +65,26 @@ api = "0.2"
id = "paketo-buildpacks/bundle-install"
version = "0.1.2"

[[order.group]]
id = "paketo-buildpacks/node-engine"
version = "0.1.4"
optional = true

[[order.group]]
id = "paketo-buildpacks/yarn"
version = "0.1.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/yarn-install"
version = "0.2.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/rails-assets"
version = "0.0.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/thin"
version = "0.0.46"
Expand All @@ -68,6 +108,26 @@ api = "0.2"
id = "paketo-buildpacks/bundle-install"
version = "0.1.2"

[[order.group]]
id = "paketo-buildpacks/node-engine"
version = "0.1.4"
optional = true

[[order.group]]
id = "paketo-buildpacks/yarn"
version = "0.1.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/yarn-install"
version = "0.2.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/rails-assets"
version = "0.0.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/unicorn"
version = "0.0.44"
Expand All @@ -91,6 +151,26 @@ api = "0.2"
id = "paketo-buildpacks/bundle-install"
version = "0.1.2"

[[order.group]]
id = "paketo-buildpacks/node-engine"
version = "0.1.4"
optional = true

[[order.group]]
id = "paketo-buildpacks/yarn"
version = "0.1.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/yarn-install"
version = "0.2.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/rails-assets"
version = "0.0.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/passenger"
version = "0.0.11"
Expand All @@ -114,6 +194,26 @@ api = "0.2"
id = "paketo-buildpacks/bundle-install"
version = "0.1.2"

[[order.group]]
id = "paketo-buildpacks/node-engine"
version = "0.1.4"
optional = true

[[order.group]]
id = "paketo-buildpacks/yarn"
version = "0.1.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/yarn-install"
version = "0.2.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/rails-assets"
version = "0.0.1"
optional = true

[[order.group]]
id = "paketo-buildpacks/rackup"
version = "0.0.49"
Expand Down
1 change: 1 addition & 0 deletions integration/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestIntegration(t *testing.T) {
suite("Passenger", testPassenger)
suite("Puma", testPuma)
suite("Rackup", testRackup)
suite("RailsAssets", testRailsAssets)
suite("Rake", testRake)
suite("Thin", testThin)
suite("Unicorn", testUnicorn)
Expand Down
99 changes: 99 additions & 0 deletions integration/rails_assets_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package integration_test

import (
"fmt"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"testing"

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

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

func testRailsAssets(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()
docker = occam.NewDocker()
})

context("when building a rails 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())

source, err = occam.Source(filepath.Join("testdata", "rails"))
Expect(err).NotTo(HaveOccurred())
})

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

it("creates a working OCI image with rails assets precompiled", func() {
var err error
var logs fmt.Stringer
image, logs, err = pack.WithNoColor().Build.
WithBuildpacks(rubyBuildpack).
WithPullPolicy("never").
Execute(name, source)
Expect(err).NotTo(HaveOccurred(), logs.String())

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

Eventually(container).Should(BeAvailable())

response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("8080")))
Expect(err).NotTo(HaveOccurred())
defer response.Body.Close()

Expect(response.StatusCode).To(Equal(http.StatusOK))

content, err := ioutil.ReadAll(response.Body)
Expect(err).NotTo(HaveOccurred())
Expect(string(content)).To(ContainSubstring("Hello World!"))

Expect(logs).To(ContainLines(ContainSubstring("MRI Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Bundler Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Bundle Install Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Yarn Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Yarn Install Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Rails Assets Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Puma Buildpack")))
Expect(logs).NotTo(ContainLines(ContainSubstring("Procfile Buildpack")))
})
})
}
1 change: 1 addition & 0 deletions integration/testdata/rails/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
defaults
27 changes: 27 additions & 0 deletions integration/testdata/rails/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/tmp/pids


/public/assets
.byebug_history

# Ignore master key for decrypting credentials and more.
/config/master.key

/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity
1 change: 1 addition & 0 deletions integration/testdata/rails/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-2.6.3
14 changes: 14 additions & 0 deletions integration/testdata/rails/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '~> 2.6.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.4'
# Use Puma as the app server
gem 'puma', '~> 4.1'

# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
Loading

0 comments on commit 6bc3980

Please sign in to comment.