-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from litmus/amazon-linux-docker
Add Github Action to validate nuget package runs on Lambda
- Loading branch information
Showing
7 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Validate Nuget Package Docker Build | ||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.x | ||
- run: dotnet tool install -g Amazon.Lambda.Tools | ||
- name: Build and package nuget | ||
uses: cake-build/cake-action@v1 | ||
with: | ||
cake-version: 1.3.0 | ||
- name: Build and package lambda | ||
working-directory: ./sample/SampleLambda | ||
run: dotnet lambda package SampleLambda --profile default --region us-west-1 | ||
- name: Run docker | ||
run: docker run --detach -p 9000:8080 samplelambda:latest | ||
- name: Test function | ||
run: curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# You can also pull these images from DockerHub amazon/aws-lambda-dotnet:7 | ||
FROM public.ecr.aws/lambda/dotnet:7 | ||
|
||
# Set the image's internal work directory | ||
WORKDIR /var/task | ||
|
||
# Copy function code | ||
COPY "bin/Release/lambda-publish" . | ||
|
||
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) | ||
CMD [ "SampleLambda::SampleLambda.HelloWorldHandler::Handle" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Amazon.Lambda.Core; | ||
using HeadlessChromium.Puppeteer.Lambda.Dotnet; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace SampleLambda | ||
{ | ||
public class HelloWorldHandler | ||
{ | ||
[LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] | ||
public async Task<byte[]> Handle(ILambdaContext context) | ||
{ | ||
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); | ||
var browserLauncher = new HeadlessChromiumPuppeteerLauncher(loggerFactory); | ||
|
||
await using (var browser = await browserLauncher.LaunchAsync()) | ||
await using (var page = await browser.NewPageAsync()) | ||
{ | ||
await page.GoToAsync("https://www.google.com"); | ||
await page.ScreenshotAsync("./google.png"); | ||
} | ||
|
||
return await File.ReadAllBytesAsync("./google.png"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="aws-lambda-tools-defaults.json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="aws-lambda-tools-defaults.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" /> | ||
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="2.1.1" /> | ||
<PackageReference Include="HeadlessChromium.Puppeteer.Lambda.Dotnet" Version="1.1.0-dev" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" /> | ||
<PackageReference Include="PuppeteerSharp" Version="11.0.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"configuration": "Release", | ||
"framework": "net7.0", | ||
"function-runtime": "dotnet7", | ||
"function-memory-size": 1536, | ||
"function-timeout": 60, | ||
"function-handler": "SampleLambda::SampleLambda.HelloWorldHandler::Handle", | ||
"package-type": "image", | ||
"docker-host-build-output-dir": "./bin/Release/lambda-publish" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="MyLocalSharedSource" value="..\..\artifacts\" /> | ||
</packageSources> | ||
</configuration> |