Skip to content

Commit

Permalink
Merge pull request #16 from opiethehokie/kestrel
Browse files Browse the repository at this point in the history
remove nowin, use kestrel instead
  • Loading branch information
jgawor committed Sep 4, 2015
2 parents 211f1ec + e513e79 commit fa2e8be
Show file tree
Hide file tree
Showing 37 changed files with 700 additions and 519 deletions.
6 changes: 4 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
AllCops:
Excludes:
- compile-extensions/**
Exclude:
- compile-extensions/**/*
Documentation:
Enabled: false
LineLength:
Expand All @@ -10,3 +10,5 @@ MethodLength:
Max: 25
ParameterLists:
Max: 12
Metrics/AbcSize:
Max: 40
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.5.0 Aug 17, 2015

- Removed Nowin server, replaced with use of Kestrel which allows the buildpack to run beta4 - beta6 apps.

## v0.4.0 Aug 05, 2015

- Add support for beta6 apps
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source "https://rubygems.org"
source 'https://rubygems.org'

gem 'rspec', '~> 3.3.0'
gem 'rake', '~> 10.4.2'

gem 'rubocop', '~> 0.33.0'
15 changes: 15 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
GEM
remote: https://rubygems.org/
specs:
ast (2.1.0)
astrolabe (1.3.1)
parser (~> 2.2)
diff-lcs (1.2.5)
parser (2.2.2.6)
ast (>= 1.1, < 3.0)
powerpack (0.1.1)
rainbow (2.0.0)
rake (10.4.2)
rspec (3.3.0)
rspec-core (~> 3.3.0)
Expand All @@ -16,10 +23,18 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
rubocop (0.33.0)
astrolabe (~> 1.3)
parser (>= 2.2.2.5, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.5)

PLATFORMS
ruby

DEPENDENCIES
rake (~> 10.4.2)
rspec (~> 3.3.0)
rubocop (~> 0.33.0)
19 changes: 5 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cloud Foundry buildpack: ASP.NET 5

A Cloud Foundry buildpack for ASP.NET 5 ([beta6][]) apps. For more information about ASP.NET 5 see:
A Cloud Foundry buildpack for ASP.NET 5 applications (tested with [beta6][] applications). For more information about ASP.NET 5 see:

* https://github.com/aspnet/home
* http://docs.asp.net/en/latest/conceptual-overview/aspnet.html
Expand All @@ -11,21 +11,14 @@ A Cloud Foundry buildpack for ASP.NET 5 ([beta6][]) apps. For more information a
cf push my_app -b https://github.com/cloudfoundry-community/asp.net5-buildpack.git
```

This buildpack will be used if there is a `NuGet.Config` file in the root directory of your project.
This buildpack will be used if there is a `NuGet.Config` file in the root directory of your project and one or more 'project.json' files anywhere.

The application structure would then be:
- NuGet.Config
- src
- project directory
- Startup.cs
- project.json
- wwwroot
- Models/Views/Controllers or other directories
Use a 'global.json' file to specify the desired DNX version if different than the latest stable beta release. Also make sure the application includes a 'kestrel' command and the corresponding dependency as that is what the buildpack will use to run the application.

For a basic example see this [Hello World sample][].

## Disconnected environments
Disconnected environments are not fully supported. The .NET Version Manager, .NET Execution Environment and NuGet packages required by the application are always downloaded during staging. The Mono binaries, however, can be cached or uncached.
Disconnected environments are not fully supported. The .NET Version Manager, .NET Execution Environment and NuGet packages required by the application are always downloaded during staging. The Mono and libuv binaries, however, can be cached or uncached.

## Building

Expand All @@ -43,7 +36,7 @@ Disconnected environments are not fully supported. The .NET Version Manager, .NE

3. Build the buildpack

`uncached` means a TAR file containing Mono will be downloaded the first time an application is staged, and `cached` means it will be packaged in the buildpack ZIP.
`uncached` means a TAR files containing Mono and libuv will be downloaded the first time an application is staged, and `cached` means they will be packaged in the buildpack ZIP.

```shell
BUNDLE_GEMFILE=cf.Gemfile bundle exec buildpack-packager [ uncached | cached ]
Expand All @@ -68,6 +61,4 @@ Open an issue on this project.


[Hello World sample]: https://github.com/IBM-Bluemix/asp.net5-helloworld
[beta4]: https://github.com/aspnet/Home/releases/tag/v1.0.0-beta4
[beta5]: https://github.com/aspnet/Home/releases/tag/v1.0.0-beta5
[beta6]: https://github.com/aspnet/Home/releases/tag/v1.0.0-beta6
7 changes: 4 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@


require 'rake'
require 'rspec/core/rake_task'

require 'rubocop/rake_task'
RuboCop::RakeTask.new

RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = Dir.glob('spec/**/*_spec.rb')
end

task :default => :spec
task default: [:spec]
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
0.5.0
1 change: 0 additions & 1 deletion bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ if AspNet5Buildpack.compile(build_dir, cache_dir)
else
exit 1
end

1 change: 0 additions & 1 deletion cf.Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
source "https://rubygems.org"

gem 'rspec', '~> 3.1.0'
gem 'buildpack-packager', github: 'cf-buildpacks/buildpack-packager', tag: 'v2.2.0'
1 change: 0 additions & 1 deletion cf.Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ PLATFORMS

DEPENDENCIES
buildpack-packager!
rspec (~> 3.1.0)
3 changes: 1 addition & 2 deletions lib/buildpack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def self.compiler(build_dir, cache_dir)
build_dir,
cache_dir,
MonoInstaller.new(build_dir, shell),
File.expand_path('../../resources/Nowin.vNext', __FILE__),
LibuvInstaller.new(build_dir, shell),
DnvmInstaller.new(shell),
Mozroots.new(shell),
DnxInstaller.new(shell),
Expand All @@ -51,5 +51,4 @@ def self.out
def self.shell
@shell ||= Shell.new
end

end
File renamed without changes.
69 changes: 69 additions & 0 deletions lib/buildpack/compile/app_dir.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Encoding: utf-8
# ASP.NET 5 Buildpack
# Copyright 2015 the original author or authors.
#
# 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
#
# http://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.

module AspNet5Buildpack
class AppDir
DEPLOYMENT_FILE_NAME = '.deployment'.freeze

def initialize(dir, out)
@dir = dir
@out = out
end

def root
@dir
end

def release_yml_path
File.join(@dir, 'aspnet5-buildpack-release.yml')
end

def startup_script_path
File.join(@dir, '.profile.d', 'startup.sh')
end

def with_command(cmd)
with_project_json.select { |d| !commands(d)[cmd].nil? && commands(d)[cmd] != '' }
end

def with_project_json
Dir.glob(File.join(@dir, '**', 'project.json')).map do |d|
Pathname.new(File.dirname(d)).relative_path_from(Pathname.new(@dir))
end
end

def project_json(dir)
File.join(@dir, dir, 'project.json')
end

def commands(dir)
JSON.load(IO.read(project_json(dir), encoding: 'bom|utf-8')).fetch('commands', {})
end

def deployment_file_project
paths = with_project_json
deployment_file = File.expand_path(File.join(@dir, DEPLOYMENT_FILE_NAME))
File.foreach(deployment_file) do |line|
m = /project = (.*)/.match(line)
if m
path = Pathname.new(m[1])
return path if paths.include?(path)
end
end if File.exist?(deployment_file)
nil
end
end
end
6 changes: 5 additions & 1 deletion lib/buildpack/compile/dnu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative 'app_dir'

module AspNet5Buildpack
class DNU
def initialize(shell)
Expand All @@ -22,8 +24,10 @@ def initialize(shell)

def restore(dir, out)
@shell.env['HOME'] = dir
@shell.env['MONO_THREADS_PER_CPU'] = '2000'
@shell.path << '/app/mono/bin'
cmd = "bash -c 'source #{dir}/.dnx/dnvm/dnvm.sh; dnvm use default -r mono -a x64; cd #{dir}; dnu restore'"
project_list = AppDir.new(dir, out).with_project_json.join(' ')
cmd = "bash -c 'source #{dir}/.dnx/dnvm/dnvm.sh; dnvm use default -r mono -a x64; cd #{dir}; dnu restore #{project_list}'"
@shell.exec(cmd, out)
end
end
Expand Down
27 changes: 2 additions & 25 deletions lib/buildpack/compile/dnx_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'json'
require_relative 'dnx_version'

module AspNet5Buildpack
class DnxInstaller

DNX_VERSION_FILE_NAME = 'global.json'.freeze
DEFAULT_DNX_VERSION = 'latest'.freeze

def initialize(shell)
@shell = shell
end

def install(dir, out)
@shell.env['HOME'] = dir
@shell.path << '/app/mono/bin'
version = dnx_version(dir, out)
version = DnxVersion.new.version(dir, out)
@shell.exec("bash -c 'source #{dir}/.dnx/dnvm/dnvm.sh; dnvm install #{version} -p -r mono'", out)
end

private

def dnx_version(dir, out)
dnx_version = DEFAULT_DNX_VERSION
version_file = File.expand_path(File.join(dir, DNX_VERSION_FILE_NAME))
if File.exists?(version_file)
begin
global_props = JSON.parse(File.read(version_file, encoding: 'bom|utf-8'))
if global_props.has_key?('sdk')
sdk = global_props['sdk']
dnx_version = sdk['version'] if sdk.has_key?('version')
end
rescue
out.warn("File #{version_file} is not valid JSON")
end
end
dnx_version
end
end
end
41 changes: 41 additions & 0 deletions lib/buildpack/compile/dnx_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Encoding: utf-8
# ASP.NET 5 Buildpack
# Copyright 2015 the original author or authors.
#
# 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
#
# http://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.

require 'json'

module AspNet5Buildpack
class DnxVersion
DNX_VERSION_FILE_NAME = 'global.json'.freeze
DEFAULT_DNX_VERSION = 'latest'.freeze

def version(dir, out)
dnx_version = DEFAULT_DNX_VERSION
version_file = File.expand_path(File.join(dir, DNX_VERSION_FILE_NAME))
if File.exist?(version_file)
begin
global_props = JSON.parse(File.read(version_file, encoding: 'bom|utf-8'))
if global_props.key?('sdk')
sdk = global_props['sdk']
dnx_version = sdk['version'] if sdk.key?('version')
end
rescue
out.warn("File #{version_file} is not valid JSON")
end
end
dnx_version
end
end
end
Loading

0 comments on commit fa2e8be

Please sign in to comment.