Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'dotnet/master' into fix-ingress-static-…
Browse files Browse the repository at this point in the history
…files
  • Loading branch information
areller committed Jul 16, 2020
2 parents 76cf4d6 + 7e0a683 commit 0664587
Show file tree
Hide file tree
Showing 232 changed files with 8,801 additions and 639 deletions.
3 changes: 3 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<Import Project="$(RepoRoot)test\Test.Infrastructure\Microsoft.AspNetCore.Testing.props" Condition=" '$(IsTestProject)' == 'true' " />


</Project>
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ while [[ -h $source ]]; do
done

scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
"$scriptroot/eng/common/build.sh" --pack --build --restore $@
"$scriptroot/eng/common/build.sh" --build --restore $@
24 changes: 20 additions & 4 deletions docs/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,26 @@ On macOS/Linux:

## Using local builds

The easiest way to use a custom build of tye is to `dotnet run -p <path to tye projet>`.
The easiest way to use a custom build of tye is to `dotnet run -p <path to tye project>`.

If you want to install your build as a dotnet global tool, that is possible as well. Building the repo will create packages in the artifacts folder that can be used.
If you want to install your build as a dotnet global tool, that is possible as well with the following steps:

1. Building the repo and create packages in the artifacts folder that can be used

On Windows:

```ps1
.\build.cmd -pack
```

On macOS/Linux:

```bash
./build.sh --pack
```

2. Install the package

```sh
dotnet install tye -g --version "0.1.0-dev" --add-source ./artifacts/packages/Debug/Shipping
```
dotnet tool install microsoft.tye -g --version "0.4.0-dev" --add-source ./artifacts/packages/Debug/Shipping
```
85 changes: 85 additions & 0 deletions docs/recipes/azure_functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Using Tye and Azure Functions

[Azure Functions](https://azure.microsoft.com/en-us/services/functions/) is a popular serverless compute platform from Azure. Tye supports running Azure functions locally.

## Getting Started: Create an Azure Function

Starting from the [sample here](https://github.com/dotnet/tye/tree/master/samples/frontend-backend), we are going to transform the backend from a web application to an azure function app.

To start, create an Azure Function project in a folder called `backend-function`. You can do this via:
- [Visual Studio Code](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-vs-code?pivots=programming-language-csharp)
- [Visual Studio](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-your-first-function-visual-studio)
- [Commandline](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function-azure-cli?tabs=bash%2Cbrowser&pivots=programming-language-csharp)

Next, you must have the [Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=windows%2Ccsharp%2Cbash) through npm. By default, if you created an azure function through VSCode or Commandline, you will already have installed it. Otherwise, you can install the core tools by running:

```bash
npm install -g azure-functions-core-tools@3
```

You can also specify a path to func by specifying `pathToFunc` for the azure function service.

Next, create an HttpTrigger called `MyHttpTrigger` in your functions project. Change the contents of MyHttpTrigger to the following:

```c#
[FunctionName("MyHttpTrigger")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");

var backendInfo = new BackendInfo()
{
IP = req.HttpContext.Connection.LocalIpAddress.ToString(),
Hostname = System.Net.Dns.GetHostName(),
};

return new OkObjectResult(backendInfo);
}

class BackendInfo
{
public string IP { get; set; } = default!;

public string Hostname { get; set; } = default!;
}
```

Finally, change line in the frontend's `Startup.cs` to call the right endpoint (line 63), changing "/" to "api/MyHttpTrigger".

```c#
endpoints.MapGet("/", async context =>
{
var bytes = await httpClient.GetByteArrayAsync("/api/MyHttpTrigger");
var backendInfo = JsonSerializer.Deserialize<BackendInfo>(bytes, options);
...
}
```

## Adding your Azure Function in tye.yaml

Now that we have a backend function added, you can simply modify your tye.yaml to point to the azure function instead:

```yaml
# tye application configuration file
# read all about it at https://github.com/dotnet/tye
name: frontend-backend
services:
- name: backend
azureFunction: backend-function/ # folder path to the azure function.
- name: frontend
project: frontend/frontend.csproj
```

## Running locally

You can now run the application locally by doing `tye run`.

On first run of an app that requires functions, tye will install any tools necessary to run functions apps in the future. This may take a while on first run, but will be saved afterwards.

Navigate to the tye dashboard to see both the frontend and backend running. Navigate to the frontend to see that the app still has the same behavior as before.

## Deployment

Deployment of azure functions is currently not supported.
8 changes: 8 additions & 0 deletions docs/reference/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ A path to another tye.yaml to be used by the application.

A reference to a repository that will be cloned and used by the application. By default, it is a string that would be passed after `git clone`.

#### `azureFunction` (string)

A path to a folder which contains an azure function project.

#### `pathToFunc` (string)

An optional path to the Azure Functions host to be used instead of the default one installed by npm.

## Environment Variables

`EnvironmentVariable` elements appear in a list inside the `env` property of a `Service`.
Expand Down
20 changes: 10 additions & 10 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
<ProductDependencies>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="5.0.0-beta.20228.4">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="5.0.0-beta.20330.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>590a102630c7efc7ca6f652f7c6c47dee4c4086c</Sha>
<Sha>243cc92161ad44c2a07464425892daee19121c99</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Feed" Version="5.0.0-beta.20228.4">
<Dependency Name="Microsoft.DotNet.Build.Tasks.Feed" Version="5.0.0-beta.20330.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>590a102630c7efc7ca6f652f7c6c47dee4c4086c</Sha>
<Sha>243cc92161ad44c2a07464425892daee19121c99</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.SignTool" Version="5.0.0-beta.20228.4">
<Dependency Name="Microsoft.DotNet.SignTool" Version="5.0.0-beta.20330.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>590a102630c7efc7ca6f652f7c6c47dee4c4086c</Sha>
<Sha>243cc92161ad44c2a07464425892daee19121c99</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="5.0.0-beta.20228.4">
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="5.0.0-beta.20330.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>590a102630c7efc7ca6f652f7c6c47dee4c4086c</Sha>
<Sha>243cc92161ad44c2a07464425892daee19121c99</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.SwaggerGenerator.MSBuild" Version="5.0.0-beta.20228.4">
<Dependency Name="Microsoft.DotNet.SwaggerGenerator.MSBuild" Version="5.0.0-beta.20330.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>590a102630c7efc7ca6f652f7c6c47dee4c4086c</Sha>
<Sha>243cc92161ad44c2a07464425892daee19121c99</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Maestro.Client" Version="1.1.0-beta.19556.4">
<Uri>https://github.com/dotnet/arcade-services</Uri>
Expand Down
6 changes: 5 additions & 1 deletion eng/common/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Param(
[switch] $publish,
[switch] $clean,
[switch][Alias('bl')]$binaryLog,
[switch][Alias('nobl')]$excludeCIBinarylog,
[switch] $ci,
[switch] $prepareMachine,
[switch] $help,
Expand Down Expand Up @@ -58,6 +59,7 @@ function Print-Usage() {
Write-Host "Advanced settings:"
Write-Host " -projects <value> Semi-colon delimited list of sln/proj's to build. Globbing is supported (*.sln)"
Write-Host " -ci Set when running on CI server"
Write-Host " -excludeCIBinarylog Don't output binary log (short: -nobl)"
Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build"
Write-Host " -warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false')"
Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)."
Expand Down Expand Up @@ -134,7 +136,9 @@ try {
}

if ($ci) {
$binaryLog = $true
if (-not $excludeCIBinarylog) {
$binaryLog = $true
}
$nodeReuse = $false
}

Expand Down
9 changes: 8 additions & 1 deletion eng/common/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ usage()
echo "Advanced settings:"
echo " --projects <value> Project or solution file(s) to build"
echo " --ci Set when running on CI server"
echo " --excludeCIBinarylog Don't output binary log (short: -nobl)"
echo " --prepareMachine Prepare machine for CI run, clean up processes after build"
echo " --nodeReuse <value> Sets nodereuse msbuild parameter ('true' or 'false')"
echo " --warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false')"
Expand Down Expand Up @@ -68,6 +69,7 @@ clean=false
warn_as_error=true
node_reuse=true
binary_log=false
exclude_ci_binary_log=false
pipelines_log=false

projects=''
Expand Down Expand Up @@ -98,6 +100,9 @@ while [[ $# > 0 ]]; do
-binarylog|-bl)
binary_log=true
;;
-excludeCIBinarylog|-nobl)
exclude_ci_binary_log=true
;;
-pipelineslog|-pl)
pipelines_log=true
;;
Expand Down Expand Up @@ -156,8 +161,10 @@ done

if [[ "$ci" == true ]]; then
pipelines_log=true
binary_log=true
node_reuse=false
if [[ "$exclude_ci_binary_log" == false ]]; then
binary_log=true
fi
fi

. "$scriptroot/tools.sh"
Expand Down
7 changes: 0 additions & 7 deletions eng/common/cross/armel/tizen-build-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ if [[ -z "$ROOTFS_DIR" ]]; then
exit 1;
fi

# Clean-up (TODO-Cleanup: We may already delete $ROOTFS_DIR at ./cross/build-rootfs.sh.)
# hk0110
if [ -d "$ROOTFS_DIR" ]; then
umount $ROOTFS_DIR/*
rm -rf $ROOTFS_DIR
fi

TIZEN_TMP_DIR=$ROOTFS_DIR/tizen_tmp
mkdir -p $TIZEN_TMP_DIR

Expand Down
71 changes: 68 additions & 3 deletions eng/common/cross/build-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ usage()
echo "BuildArch can be: arm(default), armel, arm64, x86"
echo "CodeName - optional, Code name for Linux, can be: trusty, xenial(default), zesty, bionic, alpine. If BuildArch is armel, LinuxCodeName is jessie(default) or tizen."
echo " for FreeBSD can be: freebsd11 or freebsd12."
echo " for illumos can be: illumos."
echo "lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine and FReeBSD"
echo "--skipunmount - optional, will skip the unmount of rootfs folder."
echo "--use-mirror - optional, use mirror URL to fetch resources, when available."
exit 1
}

Expand Down Expand Up @@ -67,6 +69,13 @@ __FreeBSDPackages+=" libinotify"
__FreeBSDPackages+=" lttng-ust"
__FreeBSDPackages+=" krb5"

__IllumosPackages="icu-64.2nb2"
__IllumosPackages+=" mit-krb5-1.16.2nb4"
__IllumosPackages+=" openssl-1.1.1e"
__IllumosPackages+=" zlib-1.2.11"

__UseMirror=0

__UnprocessedBuildArgs=
while :; do
if [ $# -le 0 ]; then
Expand Down Expand Up @@ -158,8 +167,8 @@ while :; do
__LLDB_Package="liblldb-6.0-dev"
;;
tizen)
if [ "$__BuildArch" != "armel" ]; then
echo "Tizen is available only for armel."
if [ "$__BuildArch" != "armel" ] && [ "$__BuildArch" != "arm64" ]; then
echo "Tizen is available only for armel and arm64."
usage;
exit 1;
fi
Expand All @@ -179,13 +188,21 @@ while :; do
__BuildArch=x64
__SkipUnmount=1
;;
illumos)
__CodeName=illumos
__BuildArch=x64
__SkipUnmount=1
;;
--skipunmount)
__SkipUnmount=1
;;
--rootfsdir|-rootfsdir)
shift
__RootfsDir=$1
;;
--use-mirror)
__UseMirror=1
;;
*)
__UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
;;
Expand Down Expand Up @@ -214,6 +231,9 @@ if [ -d "$__RootfsDir" ]; then
rm -rf $__RootfsDir
fi

mkdir -p $__RootfsDir
__RootfsDir="$( cd "$__RootfsDir" && pwd )"

if [[ "$__CodeName" == "alpine" ]]; then
__ApkToolsVersion=2.9.1
__AlpineVersion=3.9
Expand Down Expand Up @@ -257,6 +277,51 @@ elif [[ "$__CodeName" == "freebsd" ]]; then
# install packages we need.
INSTALL_AS_USER=$(whoami) $__RootfsDir/host/sbin/pkg -r $__RootfsDir -C $__RootfsDir/usr/local/etc/pkg.conf update
INSTALL_AS_USER=$(whoami) $__RootfsDir/host/sbin/pkg -r $__RootfsDir -C $__RootfsDir/usr/local/etc/pkg.conf install --yes $__FreeBSDPackages
elif [[ "$__CodeName" == "illumos" ]]; then
mkdir "$__RootfsDir/tmp"
pushd "$__RootfsDir/tmp"
JOBS="$(getconf _NPROCESSORS_ONLN)"
echo "Downloading sysroot."
wget -O - https://github.com/illumos/sysroot/releases/download/20181213-de6af22ae73b-v1/illumos-sysroot-i386-20181213-de6af22ae73b-v1.tar.gz | tar -C "$__RootfsDir" -xzf -
echo "Building binutils. Please wait.."
wget -O - https://ftp.gnu.org/gnu/binutils/binutils-2.33.1.tar.bz2 | tar -xjf -
mkdir build-binutils && cd build-binutils
../binutils-2.33.1/configure --prefix="$__RootfsDir" --target="x86_64-sun-solaris2.10" --program-prefix="x86_64-illumos-" --with-sysroot="$__RootfsDir"
make -j "$JOBS" && make install && cd ..
echo "Building gcc. Please wait.."
wget -O - https://ftp.gnu.org/gnu/gcc/gcc-8.4.0/gcc-8.4.0.tar.xz | tar -xJf -
CFLAGS="-fPIC"
CXXFLAGS="-fPIC"
CXXFLAGS_FOR_TARGET="-fPIC"
CFLAGS_FOR_TARGET="-fPIC"
export CFLAGS CXXFLAGS CXXFLAGS_FOR_TARGET CFLAGS_FOR_TARGET
mkdir build-gcc && cd build-gcc
../gcc-8.4.0/configure --prefix="$__RootfsDir" --target="x86_64-sun-solaris2.10" --program-prefix="x86_64-illumos-" --with-sysroot="$__RootfsDir" --with-gnu-as \
--with-gnu-ld --disable-nls --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv --disable-libcilkrts --disable-libada --disable-libsanitizer \
--disable-libquadmath-support --disable-shared --enable-tls
make -j "$JOBS" && make install && cd ..
BaseUrl=https://pkgsrc.joyent.com
if [[ "$__UseMirror" == 1 ]]; then
BaseUrl=http://pkgsrc.smartos.skylime.net
fi
BaseUrl="$BaseUrl"/packages/SmartOS/2020Q1/x86_64/All
echo "Downloading dependencies."
read -ra array <<<"$__IllumosPackages"
for package in "${array[@]}"; do
echo "Installing $package..."
wget "$BaseUrl"/"$package".tgz
ar -x "$package".tgz
tar --skip-old-files -xzf "$package".tmp.tgz -C "$__RootfsDir" 2>/dev/null
done
echo "Cleaning up temporary files."
popd
rm -rf "$__RootfsDir"/{tmp,+*}
mkdir -p "$__RootfsDir"/usr/include/net
mkdir -p "$__RootfsDir"/usr/include/netpacket
wget -P "$__RootfsDir"/usr/include/net https://github.com/raw/illumos/illumos-gate/master/usr/src/uts/common/io/bpf/net/bpf.h
wget -P "$__RootfsDir"/usr/include/net https://github.com/raw/illumos/illumos-gate/master/usr/src/uts/common/io/bpf/net/dlt.h
wget -P "$__RootfsDir"/usr/include/netpacket https://github.com/raw/illumos/illumos-gate/master/usr/src/uts/common/inet/sockmods/netpacket/packet.h
wget -P "$__RootfsDir"/usr/include/sys https://github.com/raw/illumos/illumos-gate/master/usr/src/uts/common/sys/sdt.h
elif [[ -n $__CodeName ]]; then
qemu-debootstrap --arch $__UbuntuArch $__CodeName $__RootfsDir $__UbuntuRepo
cp $__CrossDir/$__BuildArch/sources.list.$__CodeName $__RootfsDir/etc/apt/sources.list
Expand All @@ -275,7 +340,7 @@ elif [[ -n $__CodeName ]]; then
patch -p1 < $__CrossDir/$__BuildArch/trusty-lttng-2.4.patch
popd
fi
elif [ "$__Tizen" == "tizen" ]; then
elif [[ "$__Tizen" == "tizen" ]]; then
ROOTFS_DIR=$__RootfsDir $__CrossDir/$__BuildArch/tizen-build-rootfs.sh
else
echo "Unsupported target platform."
Expand Down
Loading

0 comments on commit 0664587

Please sign in to comment.