Skip to content

Commit

Permalink
Merge pull request #37 from degrim/DotnetCLI
Browse files Browse the repository at this point in the history
Use Dotnet CLI
  • Loading branch information
opiethehokie committed May 16, 2016
2 parents 5463128 + 85a4691 commit b2081e9
Show file tree
Hide file tree
Showing 30 changed files with 315 additions and 560 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v0.8.0 May 20, 2016
- Switch to .NET CLI from DNX
- Add support for RC2 apps
- Remove support for RC1 and lower apps using DNX
- detect now looks for project.json files or *.runtimeconfig.json files from publish output
- global.json is no longer used to specify runtime version
- Remove support for lucid64 stack

## 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
Expand Down
14 changes: 14 additions & 0 deletions Dockerfile.gettext
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# To build gettext and extract the files from the Docker container:
# export CF_STACK=cflinuxfs2
# export GETTEXT_VERSION=0.19.7
# cat Dockerfile.gettext | envsubst | docker build -t gettext-${CF_STACK}-${GETTEXT_VERSION} -
# docker run -v /somehostdir:/built --rm gettext-${CF_STACK}-${GETTEXT_VERSION} /bin/bash -c "cd /usr/local && tar czf /built/gettext-${CF_STACK}-${GETTEXT_VERSION}.tar.gz ./lib/**"

FROM cloudfoundry/$CF_STACK

RUN curl -sSL http://ftpmirror.gnu.org/gettext/gettext-${GETTEXT_VERSION}.tar.gz | tar zxfv - -C /usr/local/src \
&& cd /usr/local/src/gettext-${GETTEXT_VERSION} \
&& ./configure \
&& make \
&& make install \
&& rm -rf /usr/local/src/gettext-${GETTEXT_VERSION}
4 changes: 2 additions & 2 deletions Dockerfile.libunwind
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

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 \
RUN curl -sSL 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
&& make install \
&& rm -rf /usr/local/src/libunwind-${LIBUNWIND_VERSION}
21 changes: 0 additions & 21 deletions Dockerfile.libuv

This file was deleted.

27 changes: 18 additions & 9 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 web applications. Tested with [beta8][] applications that target .NET Core.
A Cloud Foundry buildpack for ASP.NET 5 web applications. Tested with [RC2][] applications that target .NET Core.

For more information about ASP.NET 5 see:

Expand All @@ -13,18 +13,27 @@ For more information about ASP.NET 5 see:
cf push my_app -b https://github.com/cloudfoundry-community/asp.net5-buildpack.git
```

This buildpack will be used if there are one or more `project.json` files in the pushed application.
This buildpack will be used if there are one or more `project.json` files in the pushed application, or if the application is pushed from the output directory of the `dotnet publish` command.

Also make sure the application includes a `kestrel` or a `web` command and the corresponding Microsoft.AspNet.Server.Kestrel 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.
Use a `NuGet.Config` file to specify non-default package sources.

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

## Legacy DNX support (used for RC1 apps)

With the introduction of support for the Dotnet CLI in buildpack version 0.8, apps which relied on the older DNX toolchain will no longer work with the current buildpack. If you need to keep your app running on DNX for now until you can update it to use the Dotnet CLI, use the following command:

```bash
cf push my_app -b https://github.com/cloudfoundry-community/asp.net5-buildpack.git#dnx
```

Keep in mind that this support provided to allow users time to update their apps to use the Dotnet CLI, and you should switch to using the main branch of the buildpack (using the command further above) as soon as possible.

## Disconnected environments

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-coreclr-linux-x64.1.0.0-beta7`. Then push from the `bin/output` director.
Applications can be pushed with their other dependencies after "publishing" the application like `dotnet publish`. Then push from the `bin/<Debug|Release>/<framework>/publish` directory.

## Building

Expand Down Expand Up @@ -57,11 +66,11 @@ These steps only apply to admins who wish to install the buildpack into their Cl
5. Use in Cloud Foundry
Upload the buildpack to your Cloud Foundry and optionally specify it by name
```bash
cf create-buildpack custom_aspnet5_buildpack aspnet5_buildpack-cached-custom.zip 1
cf push my_app -b custom_aspnet5_buildpack
```
```
## Contributing
Expand All @@ -73,5 +82,5 @@ Open an issue on this project.
[Hello World sample]: https://github.com/IBM-Bluemix/asp.net5-helloworld
[beta8]: https://github.com/aspnet/Home/releases/tag/v1.0.0-beta8
[RC2]: https://github.com/aspnet/Home/releases/tag/v1.0.0-rc2-final
[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.7.0
0.8.0
2 changes: 1 addition & 1 deletion compile-extensions
7 changes: 3 additions & 4 deletions lib/buildpack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ def self.compiler(build_dir, cache_dir)
Compiler.new(
build_dir,
cache_dir,
LibuvInstaller.new(build_dir, shell),
LibunwindInstaller.new(build_dir, shell),
DnvmInstaller.new(shell),
DnxInstaller.new(shell),
DNU.new(shell),
GetTextInstaller.new(build_dir, shell),
DotnetInstaller.new(shell),
Dotnet.new(shell),
Copier.new,
out)
end
Expand Down
22 changes: 19 additions & 3 deletions lib/buildpack/app_dir.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Encoding: utf-8
# ASP.NET 5 Buildpack
# Copyright 2015 the original author or authors.
# Copyright 2015-2016 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 Down Expand Up @@ -48,13 +48,29 @@ def deployment_file_project
paths = with_project_json
deployment_file = File.expand_path(File.join(@dir, DEPLOYMENT_FILE_NAME))
File.foreach(deployment_file, encoding: 'utf-8') do |line|
m = /project = (.*)/.match(line)
m = /project[ \t]*=[ \t]*(.*)/i.match(line)
if m
path = Pathname.new(m[1])
n = /.*([.](xproj|csproj))/i.match(m[1])
path = n ? Pathname.new(File.dirname(m[1])) : Pathname.new(m[1])
return path if paths.include?(path)
end
end if File.exist?(deployment_file)
nil
end

def main_project_path
path = deployment_file_project
project_paths = with_project_json
multiple_paths = project_paths.any? && !project_paths.one?
fail 'Multiple paths contain a project.json file, but no .deployment file was used' if multiple_paths unless path
path = project_paths.first unless path
path if path
end

def published_project
config_files = Dir.glob(File.join(@dir, '*.runtimeconfig.json'))
m = /(.*)[.]runtimeconfig[.]json/i.match(Pathname.new(config_files.first).basename.to_s) if config_files.one?
m[1].to_s unless m.nil?
end
end
end
58 changes: 25 additions & 33 deletions lib/buildpack/compile/compiler.rb
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 2014-2016 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 @@ -14,26 +14,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative 'libuv_installer.rb'
require_relative 'libunwind_installer.rb'
require_relative 'dnvm_installer.rb'
require_relative 'dnx_installer.rb'
require_relative 'dnu.rb'
require_relative 'gettext_installer.rb'
require_relative 'dotnet_installer.rb'
require_relative 'dotnet.rb'
require_relative '../bp_version.rb'

require 'json'
require 'pathname'

module AspNet5Buildpack
class Compiler
def initialize(build_dir, cache_dir, libuv_binary, libunwind_binary, dnvm_installer, dnx_installer, dnu, copier, out)
def initialize(build_dir, cache_dir, libunwind_binary, gettext_binary, dotnet_installer, dotnet, copier, out)
@build_dir = build_dir
@cache_dir = cache_dir
@libuv_binary = libuv_binary
@libunwind_binary = libunwind_binary
@dnvm_installer = dnvm_installer
@dnx_installer = dnx_installer
@dnu = dnu
@gettext_binary = gettext_binary
@dotnet_installer = dotnet_installer
@dotnet = dotnet
@copier = copier
@out = out
end
Expand All @@ -42,11 +40,10 @@ def compile
puts "ASP.NET 5 buildpack version: #{BuildpackVersion.new.version}\n"
puts "ASP.NET 5 buildpack starting compile\n"
step('Restoring files from buildpack cache', method(:restore_cache))
step('Extracting libuv', method(:extract_libuv))
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('Extracting gettext', method(:extract_gettext))
step('Installing Dotnet CLI', method(:install_dotnet))
step('Restoring dependencies with Dotnet CLI', method(:restore_dependencies))
step('Saving to buildpack cache', method(:save_cache))
puts "ASP.NET 5 buildpack is done creating the droplet\n"
return true
Expand All @@ -57,36 +54,32 @@ def compile

private

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

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, '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')
def extract_gettext(out)
gettext_binary.extract(File.join(build_dir, 'gettext'), out) unless File.exist? File.join(build_dir, 'gettext')
end

def install_dnvm(out)
dnvm_installer.install(build_dir, out) unless File.exist? File.join(build_dir, 'approot', 'runtimes')
def restore_cache(out)
copier.cp(File.join(cache_dir, '.nuget'), build_dir, out) if File.exist? File.join(cache_dir, '.nuget')
copier.cp(File.join(cache_dir, 'libunwind'), build_dir, out) if File.exist? File.join(cache_dir, 'libunwind')
copier.cp(File.join(cache_dir, 'gettext'), build_dir, out) if File.exist? File.join(cache_dir, 'gettext')
end

def install_dnx(out)
dnx_installer.install(build_dir, out) unless File.exist? File.join(build_dir, 'approot', 'runtimes')
def install_dotnet(out)
dotnet_installer.install(build_dir, out) unless File.exist? File.join(build_dir, 'approot', 'runtimes')
end

def restore_dependencies(out)
dnu.restore(build_dir, out) unless File.exist? File.join(build_dir, 'approot', 'packages')
dotnet.restore(build_dir, out) unless File.exist? File.join(build_dir, 'approot', 'packages')
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(build_dir, 'libuv'), cache_dir, out) unless File.exist? File.join(cache_dir, 'libuv')
copier.cp(File.join(build_dir, '.nuget'), cache_dir, out) if File.exist? File.join(build_dir, '.nuget')
copier.cp(File.join(build_dir, 'libunwind'), cache_dir, out) unless File.exist? File.join(cache_dir, 'libunwind')
copier.cp(File.join(build_dir, 'gettext'), cache_dir, out) unless File.exist? File.join(cache_dir, 'gettext')
end

def step(description, method)
Expand All @@ -103,12 +96,11 @@ def step(description, method)

attr_reader :build_dir
attr_reader :cache_dir
attr_reader :libuv_binary
attr_reader :libunwind_binary
attr_reader :dnvm_installer
attr_reader :dnx_installer
attr_reader :gettext_binary
attr_reader :dotnet_installer
attr_reader :mozroots
attr_reader :dnu
attr_reader :dotnet
attr_reader :copier
attr_reader :out
end
Expand Down
31 changes: 0 additions & 31 deletions lib/buildpack/compile/dnx_installer.rb

This file was deleted.

41 changes: 0 additions & 41 deletions lib/buildpack/compile/dnx_version.rb

This file was deleted.

Loading

0 comments on commit b2081e9

Please sign in to comment.