Skip to content

Commit

Permalink
Merge pull request #22 from opiethehokie/libunwind8
Browse files Browse the repository at this point in the history
support beta8 apps and remove mono
  • Loading branch information
jgawor committed Oct 22, 2015
2 parents 6f6f953 + 7d17a6c commit 0297b13
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 277 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## unreleased
## v0.7.0 Sep 30, 2015
- Make NuGet.Config optional, detect only looks for project.json files
- Support published apps for offline mode and faster staging
- Remove Mono
- Switch to .NET Core

## v0.6.0 Sep 10, 2015
- Add support for beta7 apps
Expand Down
14 changes: 14 additions & 0 deletions Dockerfile.libunwind
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# To build libunwind and extract the files from the Docker container:
# export CF_STACK=cflinuxfs2
# export LIBUNWIND_VERSION=1.1
# cat Dockerfile.libunwind | envsubst | docker build -t libunwind-${CF_STACK}-${LIBUNWIND_VERSION} -
# docker run -v /somehostdir:/built --rm libunwind-${CF_STACK}-${LIBUNWIND_VERSION} /bin/bash -c "cd /usr/local && tar czf /built/libunwind-${CF_STACK}-${LIBUNWIND_VERSION}.tar.gz ./include/*unwind* ./lib/libunwind*"

FROM cloudfoundry/$CF_STACK

RUN curl -SSL wget http://download.savannah.gnu.org/releases/libunwind/libunwind-${LIBUNWIND_VERSION}.tar.gz | tar zxfv - -C /usr/local/src \
&& cd /usr/local/src/libunwind-${LIBUNWIND_VERSION} \
&& ./configure \
&& make \
&& make install
&& rm -rf /usr/local/src/libunwind-${LIBUNWIND_VERSION}
20 changes: 0 additions & 20 deletions Dockerfile.mono

This file was deleted.

15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Cloud Foundry buildpack: ASP.NET 5

A Cloud Foundry buildpack for ASP.NET 5 applications (tested with [beta7][] applications). For more information about ASP.NET 5 see:
A Cloud Foundry buildpack for ASP.NET 5 web applications. Tested with [beta8][] applications that target .NET Core.

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 @@ -13,16 +15,16 @@ cf push my_app -b https://github.com/cloudfoundry-community/asp.net5-buildpack.g

This buildpack will be used if there are one or more `project.json` files in the pushed application.

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.
Also make sure the application includes a `kestrel` command and the corresponding dependency because the buildpack will use [Kestrel][] to run the application.

Use a `global.json` file to specify the desired DNX version if different than the latest stable beta release. Use a `NuGet.Config` file to specify non-default package sources.

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

## Disconnected environments
The Mono and libuv binaries can be cached with the buildpack.
The binaries in `manifest.yml` can be cached with the buildpack.

Applications can be pushed with their other dependencies after "publishing" the application like `dnu publish` or `dnu publish --runtime ~/.dnx/runtimes/dnx-mono.1.0.0-beta7`. Then push from the `bin/output` director.
Applications can be pushed with their other dependencies after "publishing" the application like `dnu publish` or `dnu publish --runtime ~/.dnx/runtimes/dnx-coreclr-linux-x64.1.0.0-beta7`. Then push from the `bin/output` director.

## Building

Expand All @@ -44,7 +46,7 @@ Applications can be pushed with their other dependencies after "publishing" the

4. Build the buildpack

`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.
`uncached` means the buildpack's binary dependencies 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 @@ -69,4 +71,5 @@ Open an issue on this project.


[Hello World sample]: https://github.com/IBM-Bluemix/asp.net5-helloworld
[beta7]: https://github.com/aspnet/Home/releases/tag/v1.0.0-beta7
[beta8]: https://github.com/aspnet/Home/releases/tag/v1.0.0-beta8
[Kestrel]: https://github.com/aspnet/KestrelHttpServer
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.0
0.7.0
3 changes: 1 addition & 2 deletions lib/buildpack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ def self.compiler(build_dir, cache_dir)
Compiler.new(
build_dir,
cache_dir,
MonoInstaller.new(build_dir, shell),
LibuvInstaller.new(build_dir, shell),
LibunwindInstaller.new(build_dir, shell),
DnvmInstaller.new(shell),
Mozroots.new(shell),
DnxInstaller.new(shell),
DNU.new(shell),
ReleaseYmlWriter.new,
Expand Down
5 changes: 2 additions & 3 deletions lib/buildpack/compile/dnu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ def initialize(shell)

def restore(dir, out)
@shell.env['HOME'] = dir
@shell.env['MONO_THREADS_PER_CPU'] = '2000'
@shell.path << '/app/mono/bin'
@shell.env['LD_LIBRARY_PATH'] = "$LD_LIBRARY_PATH:#{dir}/libunwind/lib"
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}'"
cmd = "bash -c 'source #{dir}/.dnx/dnvm/dnvm.sh; dnvm use default; cd #{dir}; dnu restore #{project_list}'"
@shell.exec(cmd, out)
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/buildpack/compile/dnx_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ def initialize(shell)

def install(dir, out)
@shell.env['HOME'] = dir
@shell.path << '/app/mono/bin'
version = DnxVersion.new.version(dir, out)
@shell.exec("bash -c 'source #{dir}/.dnx/dnvm/dnvm.sh; dnvm install #{version} -p -r mono'", out)
@shell.exec("bash -c 'source #{dir}/.dnx/dnvm/dnvm.sh; dnvm install #{version} -p -r coreclr'", out)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Encoding: utf-8
# ASP.NET 5 Buildpack
# Copyright 2014-2015 the original author or authors.
# 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.
Expand All @@ -15,27 +15,26 @@
# limitations under the License.

module AspNet5Buildpack
class MonoInstaller
# really 4.0.1.44 fix release - needed for mozroots error
DEFAULT_VERSION = '4.0.1'
class LibunwindInstaller
VERSION = '1.1'.freeze

def initialize(app_dir, shell)
@app_dir = app_dir
@shell = shell
end

def extract(dest_dir, out)
out.print("Mono version: #{version}")
out.print("libunwind version: #{version}")
cmd = "mkdir -p #{dest_dir}; curl -L `translate_dependency_url #{dependency_name}` -s | tar zxv -C #{dest_dir} &> /dev/null"
run_common_cmd(cmd, out)
end

def version
desired_version_from_monoversion_file || DEFAULT_VERSION
def libunwind_tar_gz(out)
run_common_cmd("translate_dependency_url #{dependency_name}", out)
end

def mono_tar_gz(out)
run_common_cmd("translate_dependency_url #{dependency_name}", out)
def version
VERSION
end

private
Expand All @@ -51,15 +50,7 @@ def buildpack_root
end

def dependency_name
"mono-x-#{version}.tar.gz"
end

def desired_version_from_monoversion_file
IO.read(mono_version_file) if File.exist?(mono_version_file)
end

def mono_version_file
File.join(app_dir, '.mono-version')
"libunwind-x-#{version}.tar.gz"
end

private
Expand Down
28 changes: 0 additions & 28 deletions lib/buildpack/compile/mozroots.rb

This file was deleted.

7 changes: 3 additions & 4 deletions lib/buildpack/compile/release_yml_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ def write_startup_script(startup_script)
FileUtils.mkdir_p(File.dirname(startup_script))
File.open(startup_script, 'w') do |f|
f.write 'export HOME=/app;'
f.write 'export PATH=$HOME/mono/bin:$PATH;'
f.write 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/libuv/lib;'
f.write '[ -f $HOME/.dnx/dnvm/dnvm.sh ] && { source $HOME/.dnx/dnvm/dnvm.sh; dnvm use default -r mono -a x64; }'
f.write 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/libuv/lib:$HOME/libunwind/lib;'
f.write '[ -f $HOME/.dnx/dnvm/dnvm.sh ] && { source $HOME/.dnx/dnvm/dnvm.sh; dnvm use default; }'
end
end

def write_yml(ymlPath, base_dir, web_dir)
start_cmd = File.exist?(File.join(base_dir, CFWEB_CMD)) ? "./#{CFWEB_CMD}" : "dnx --project #{web_dir} #{CFWEB_CMD}"
start_cmd = File.exist?(File.join(base_dir, 'approot', CFWEB_CMD)) ? "approot/#{CFWEB_CMD}" : "dnx --project #{web_dir} #{CFWEB_CMD}"
File.open(ymlPath, 'w') do |f|
f.write <<EOT
---
Expand Down
34 changes: 9 additions & 25 deletions lib/buildpack/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative 'compile/mozroots.rb'
require_relative 'compile/mono_installer.rb'
require_relative 'compile/libuv_installer.rb'
require_relative 'compile/libunwind_installer.rb'
require_relative 'compile/dnvm_installer.rb'
require_relative 'compile/dnx_installer.rb'
require_relative 'compile/dnu.rb'
Expand All @@ -30,14 +29,13 @@ module AspNet5Buildpack
class Compiler
WARNING_MESSAGE = 'This is an experimental buildpack. It is not supported. Do not expect it to work reliably. Please, do not contact support about issues with this buildpack.'.freeze

def initialize(build_dir, cache_dir, mono_binary, libuv_binary, dnvm_installer, mozroots, dnx_installer, dnu, release_yml_writer, copier, out)
def initialize(build_dir, cache_dir, libuv_binary, libunwind_binary, dnvm_installer, dnx_installer, dnu, release_yml_writer, copier, out)
@build_dir = build_dir
@cache_dir = cache_dir
@mono_binary = mono_binary
@libuv_binary = libuv_binary
@libunwind_binary = libunwind_binary
@dnvm_installer = dnvm_installer
@dnx_installer = dnx_installer
@mozroots = mozroots
@dnu = dnu
@release_yml_writer = release_yml_writer
@copier = copier
Expand All @@ -49,13 +47,11 @@ def compile
puts "ASP.NET 5 buildpack starting compile\n"
out.warn(WARNING_MESSAGE) unless WARNING_MESSAGE.nil?
step('Restoring files from buildpack cache', method(:restore_cache))
step('Extracting mono', method(:extract_mono))
step('Extracting libuv', method(:extract_libuv))
step('Importing Mozilla Root Certificates', method(:install_mozroot_certs))
step('Extracting libunwind', method(:extract_libunwind))
step('Installing DNVM', method(:install_dnvm))
step('Installing DNX with DNVM', method(:install_dnx))
step('Restoring dependencies with DNU', method(:restore_dependencies))
step('Moving files in to place', method(:move_to_app_dir))
step('Saving to buildpack cache', method(:save_cache))
step('Writing Release YML', method(:write_release_yml))
puts "ASP.NET 5 buildpack is done creating the droplet\n"
Expand All @@ -70,25 +66,18 @@ def compile

private

def extract_mono(out)
mono_binary.extract(File.join('/', 'app'), out) unless File.exist? File.join('/app', 'mono')
end

def extract_libuv(out)
libuv_binary.extract(File.join(build_dir, 'libuv'), out) unless File.exist? File.join(build_dir, 'libuv')
end

def install_mozroot_certs(out)
dest_dir = File.join(build_dir, '..')
mozroots.import(out)
copier.cp(File.join(Dir.home, '.config', '.mono', 'certs'), File.join(dest_dir, '.config', '.mono'), out)
def extract_libunwind(out)
libunwind_binary.extract(File.join(build_dir, 'libunwind'), out) unless File.exist? File.join(build_dir, 'libunwind')
end

def restore_cache(out)
copier.cp(File.join(cache_dir, '.dnx'), build_dir, out) if File.exist? File.join(cache_dir, '.dnx')
copier.cp(File.join(cache_dir, 'mono'), File.join('/', 'app'), out) if File.exist? File.join(cache_dir, 'mono')
copier.cp(File.join(cache_dir, 'certs'), File.join(build_dir, '..', '.config', '.mono'), out) if File.exist? File.join(cache_dir, 'certs')
copier.cp(File.join(cache_dir, 'libuv'), build_dir, out) if File.exist? File.join(cache_dir, 'libuv')
copier.cp(File.join(cache_dir, 'libunwind'), build_dir, out) if File.exist? File.join(cache_dir, 'libunwind')
end

def install_dnvm(out)
Expand All @@ -103,15 +92,10 @@ def restore_dependencies(out)
dnu.restore(build_dir, out) unless File.exist? File.join(build_dir, 'approot', 'packages')
end

def move_to_app_dir(out)
copier.cp(File.join('/app', 'mono'), build_dir, out)
end

def save_cache(out)
copier.cp(File.join(build_dir, '.dnx'), cache_dir, out) if File.exist? File.join(build_dir, '.dnx')
copier.cp(File.join('/app', 'mono'), cache_dir, out) unless File.exist? File.join(cache_dir, 'mono')
copier.cp(File.join(Dir.home, '.config', '.mono', 'certs'), cache_dir, out) unless File.exist? File.join(cache_dir, 'certs')
copier.cp(File.join(build_dir, 'libuv'), cache_dir, out) unless File.exist? File.join(cache_dir, 'libuv')
copier.cp(File.join(build_dir, 'libunwind'), cache_dir, out) unless File.exist? File.join(cache_dir, 'libunwind')
end

def write_release_yml(out)
Expand All @@ -132,8 +116,8 @@ def step(description, method)

attr_reader :build_dir
attr_reader :cache_dir
attr_reader :mono_binary
attr_reader :libuv_binary
attr_reader :libunwind_binary
attr_reader :dnvm_installer
attr_reader :dnx_installer
attr_reader :mozroots
Expand Down
33 changes: 18 additions & 15 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,42 @@
language: aspnet5

url_to_dependency_map:
- match: mono-(.*)-(\d+\.\d+\.\d+)
name: mono
version: $2
- match: libuv-(.*)-(\d+\.\d+\.\d+)
name: libuv
version: $2
- match: libunwind-(.*)-(\d+\.\d+)
name: libunwind
version: $2

dependencies:
- name: mono
version: 4.0.1
cf_stacks:
- lucid64
uri: https://github.com/cloudfoundry-community/asp.net5-buildpack/releases/download/v0.2/mono-lucid64-4.0.1.tar.gz
md5: 3d020ca4a4bc2afd6e803eeb18ff5551
- name: mono
version: 4.0.1
cf_stacks:
- cflinuxfs2
uri: https://github.com/cloudfoundry-community/asp.net5-buildpack/releases/download/v0.2/mono-cflinuxfs2-4.0.1.tar.gz
md5: 98de7244bd6a91ea4d0acc9104b82a59
- name: libuv
version: 1.4.2
cf_stacks:
- lucid64
uri: https://github.com/cloudfoundry-community/asp.net5-buildpack/releases/download/v0.5/libuv-lucid64-1.4.2.tar.gz
md5: bec8ea66006c89abb0c7314d62b82a57

- name: libuv
version: 1.4.2
cf_stacks:
- cflinuxfs2
uri: https://github.com/cloudfoundry-community/asp.net5-buildpack/releases/download/v0.5/libuv-cflinuxfs2-1.4.2.tar.gz
md5: 72ad380dbab354bbc3d0f41825c22bd0

- name: libunwind
version: 1.1
cf_stacks:
- lucid64
uri: https://s3.amazonaws.com/aspnet5/libunwind-lucid64-1.1.tar.gz
md5: c49405a4565f3ca8838983edca697df6

- name: libunwind
version: 1.1
cf_stacks:
- cflinuxfs2
uri: https://s3.amazonaws.com/aspnet5/libunwind-cflinuxfs2-1.1.tar.gz
md5: b76452a8a2400f3cfdf189761e8be97e

exclude_files:
- .git/
- .gitignore
Expand Down
Loading

0 comments on commit 0297b13

Please sign in to comment.