diff --git a/app/config/environments.php b/app/config/environments.php index 15a924ff3..9f1c5638e 100644 --- a/app/config/environments.php +++ b/app/config/environments.php @@ -106,6 +106,24 @@ $environments = [ 'logo' => 'dart.png', 'supports' => [System::X86], ], + 'dotnet-3.1' => [ + 'name' => '.NET', + 'version' => '3.1', + 'base' => 'mcr.microsoft.com/dotnet/runtime:3.1-alpine', + 'image' => 'appwrite/env-dotnet-3.1:1.0.0', + 'build' => '/usr/src/code/docker/environments/dotnet-3.1', + 'logo' => 'dotnet.png', + 'supports' => [System::X86, System::ARM], + ], + 'dotnet-5.0' => [ + 'name' => '.NET', + 'version' => '5.0', + 'base' => 'mcr.microsoft.com/dotnet/runtime:5.0-alpine', + 'image' => 'appwrite/env-dotnet-5.0:1.0.0', + 'build' => '/usr/src/code/docker/environments/dotnet-5.0', + 'logo' => 'dotnet.png', + 'supports' => [System::X86, System::ARM], + ], ]; $allowList = empty(App::getEnv('_APP_FUNCTIONS_ENVS', null)) ? false : \explode(',', App::getEnv('_APP_FUNCTIONS_ENVS', null)); diff --git a/docker/environments/build.sh b/docker/environments/build.sh index eed2c0a6c..1543c5814 100644 --- a/docker/environments/build.sh +++ b/docker/environments/build.sh @@ -32,3 +32,9 @@ docker buildx build --platform linux/amd64,linux/arm64,linux/386,linux/ppc64le - echo 'Dart 2.10...' docker buildx build --platform linux/amd64 -t appwrite/env-dart-2.10:1.0.0 ./docker/environments/dart-2.10/ --push + +echo '.NET 3.1...' +docker buildx build --platform linux/amd64,linux/arm64 -t appwrite/env-dotnet-3.1:1.0.0 ./docker/environments/dotnet-3.1/ --push + +echo '.NET 5.0...' +docker buildx build --platform linux/amd64,linux/arm64 -t appwrite/env-dotnet-5.0:1.0.0 ./docker/environments/dotnet-5.0/ --push diff --git a/docker/environments/dotnet-3.1/Dockerfile b/docker/environments/dotnet-3.1/Dockerfile new file mode 100644 index 000000000..007b47a50 --- /dev/null +++ b/docker/environments/dotnet-3.1/Dockerfile @@ -0,0 +1,7 @@ +FROM mcr.microsoft.com/dotnet/runtime:3.1-alpine + +LABEL maintainer="team@appwrite.io" + +RUN apk add tar + +WORKDIR /usr/local/src/ diff --git a/docker/environments/dotnet-5.0/Dockerfile b/docker/environments/dotnet-5.0/Dockerfile new file mode 100644 index 000000000..e259ae1e4 --- /dev/null +++ b/docker/environments/dotnet-5.0/Dockerfile @@ -0,0 +1,7 @@ +FROM mcr.microsoft.com/dotnet/runtime:5.0-alpine + +LABEL maintainer="team@appwrite.io" + +RUN apk add tar + +WORKDIR /usr/local/src/ diff --git a/public/images/environments/dotnet.png b/public/images/environments/dotnet.png new file mode 100644 index 000000000..824721f20 Binary files /dev/null and b/public/images/environments/dotnet.png differ diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index d29b0acb4..64f71a79b 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -543,6 +543,22 @@ class FunctionsCustomServerTest extends Scope 'command' => 'dart run main.dart', 'timeout' => 15, ], + [ + 'language' => '.NET', + 'version' => '3.1', + 'name' => 'dotnet-3.1', + 'code' => $functions.'/dotnet-3.1.tar.gz', + 'command' => 'dotnet dotnet.dll', + 'timeout' => 15, + ], + [ + 'language' => '.NET', + 'version' => '5.0', + 'name' => 'dotnet-5.0', + 'code' => $functions.'/dotnet-5.0.tar.gz', + 'command' => 'dotnet dotnet.dll', + 'timeout' => 15, + ], ]; sleep(count($envs) * 25); diff --git a/tests/resources/functions/dotnet-3.1.tar.gz b/tests/resources/functions/dotnet-3.1.tar.gz new file mode 100644 index 000000000..16627e89a Binary files /dev/null and b/tests/resources/functions/dotnet-3.1.tar.gz differ diff --git a/tests/resources/functions/dotnet-3.1/Program.cs b/tests/resources/functions/dotnet-3.1/Program.cs new file mode 100644 index 000000000..ee5894aa7 --- /dev/null +++ b/tests/resources/functions/dotnet-3.1/Program.cs @@ -0,0 +1,28 @@ +using System; +using Appwrite; + +namespace dotnet +{ + class Program + { + static void Main(string[] args) + { + Client client = new Client(); + + client.SetEndPoint(Environment.GetEnvironmentVariable("APPWRITE_ENDPOINT")); + client.SetProject(Environment.GetEnvironmentVariable("APPWRITE_PROJECT")); + client.SetKey(Environment.GetEnvironmentVariable("APPWRITE_SECRET")); + + Storage storage = new Storage(client); + + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ID")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_NAME")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_TAG")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_TRIGGER")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ENV_NAME")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ENV_VERSION")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_EVENT")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_EVENT_PAYLOAD")); + } + } +} diff --git a/tests/resources/functions/dotnet-3.1/dotnet.csproj b/tests/resources/functions/dotnet-3.1/dotnet.csproj new file mode 100644 index 000000000..1b2d649f6 --- /dev/null +++ b/tests/resources/functions/dotnet-3.1/dotnet.csproj @@ -0,0 +1,9 @@ + + + Exe + netcoreapp3.1 + + + + + diff --git a/tests/resources/functions/dotnet-5.0.tar.gz b/tests/resources/functions/dotnet-5.0.tar.gz new file mode 100644 index 000000000..7117cf924 Binary files /dev/null and b/tests/resources/functions/dotnet-5.0.tar.gz differ diff --git a/tests/resources/functions/dotnet-5.0/Program.cs b/tests/resources/functions/dotnet-5.0/Program.cs new file mode 100644 index 000000000..ee5894aa7 --- /dev/null +++ b/tests/resources/functions/dotnet-5.0/Program.cs @@ -0,0 +1,28 @@ +using System; +using Appwrite; + +namespace dotnet +{ + class Program + { + static void Main(string[] args) + { + Client client = new Client(); + + client.SetEndPoint(Environment.GetEnvironmentVariable("APPWRITE_ENDPOINT")); + client.SetProject(Environment.GetEnvironmentVariable("APPWRITE_PROJECT")); + client.SetKey(Environment.GetEnvironmentVariable("APPWRITE_SECRET")); + + Storage storage = new Storage(client); + + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ID")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_NAME")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_TAG")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_TRIGGER")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ENV_NAME")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_ENV_VERSION")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_EVENT")); + Console.WriteLine(Environment.GetEnvironmentVariable("APPWRITE_FUNCTION_EVENT_PAYLOAD")); + } + } +} diff --git a/tests/resources/functions/dotnet-5.0/dotnet.csproj b/tests/resources/functions/dotnet-5.0/dotnet.csproj new file mode 100644 index 000000000..84fee71f3 --- /dev/null +++ b/tests/resources/functions/dotnet-5.0/dotnet.csproj @@ -0,0 +1,9 @@ + + + Exe + net5.0 + + + + + diff --git a/tests/resources/functions/package-dotnet-3.1.sh b/tests/resources/functions/package-dotnet-3.1.sh new file mode 100644 index 000000000..f3cb92adf --- /dev/null +++ b/tests/resources/functions/package-dotnet-3.1.sh @@ -0,0 +1,12 @@ + +echo '.NET 3.1 Packaging...' + +cp -r $(pwd)/tests/resources/functions/dotnet-3.1 $(pwd)/tests/resources/functions/packages/dotnet-3.1 + +docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-3.1:/app -w /app mcr.microsoft.com/dotnet/sdk:3.1-alpine dotnet restore +docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-3.1:/app -w /app mcr.microsoft.com/dotnet/sdk:3.1-alpine dotnet publish -o ./release +docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-3.1:/app -w /app/release appwrite/env-dotnet-3.1:1.0.0 tar -zcvf ../code.tar.gz . + +mv $(pwd)/tests/resources/functions/packages/dotnet-3.1/code.tar.gz $(pwd)/tests/resources/functions/dotnet-3.1.tar.gz + +rm -r $(pwd)/tests/resources/functions/packages/dotnet-3.1 diff --git a/tests/resources/functions/package-dotnet-5.0.sh b/tests/resources/functions/package-dotnet-5.0.sh new file mode 100644 index 000000000..d12681248 --- /dev/null +++ b/tests/resources/functions/package-dotnet-5.0.sh @@ -0,0 +1,12 @@ + +echo '.NET 5.0 Packaging...' + +cp -r $(pwd)/tests/resources/functions/dotnet-5.0 $(pwd)/tests/resources/functions/packages/dotnet-5.0 + +docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-5.0:/app -w /app mcr.microsoft.com/dotnet/sdk:5.0-alpine dotnet restore +docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-5.0:/app -w /app mcr.microsoft.com/dotnet/sdk:5.0-alpine dotnet publish -o ./release +docker run --rm -v $(pwd)/tests/resources/functions/packages/dotnet-5.0:/app -w /app/release appwrite/env-dotnet-5.0:1.0.0 tar -zcvf ../code.tar.gz . + +mv $(pwd)/tests/resources/functions/packages/dotnet-5.0/code.tar.gz $(pwd)/tests/resources/functions/dotnet-5.0.tar.gz + +rm -r $(pwd)/tests/resources/functions/packages/dotnet-5.0