Run it locally
The image is built on the AWS Lambda .NET base image, which includes the Lambda runtime interface emulator. Your function runs locally exactly the way Lambda runs it, just with fewer invoices.
Build and run
Section titled “Build and run”docker compose up -d --buildCompose builds the run stage, publishes port 9000 and turns on sample data. Shut it down with docker compose down.
docker build . --target run --tag acme-reviews:localdocker run --rm -p 9000:8080 -e Database__SeedSampleData=true acme-reviews:localThen invoke it from another terminal:
curl -X POST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"limit":5}'Try the other functions
Section titled “Try the other functions”The image runs GetMovies by default. The same handler also has GetAuthors and GetReviews. Pass the function’s full handler name to docker run to start a different one.
docker run --rm -p 9000:8080 -e Database__SeedSampleData=true acme-reviews:local \ "Presentation::Acme.Reviews.Presentation.LambdaFunction.Handler::GetReviews"
curl -X POST "http://localhost:9000/2015-03-31/functions/function/invocations" \ -d '{"movieId":"e159975e-4e6a-1ffd-713e-1eb9d8d4a593","limit":2}'The sample data uses a fixed seed, so that movie id is the same on every machine. See the function reference for every request and response.
Run the tests
Section titled “Run the tests”dotnet testEach test builds its own in-memory SQLite database from the migrations and the same fixed seed. No test can change what another one sees, and nothing touches the database file in /tmp.
Run just one part of the Dockerfile
Section titled “Run just one part of the Dockerfile”The Dockerfile has a stage for each job, so you can build only what you need.
| Stage | What it does |
|---|---|
build |
Restores and builds the solution |
test |
Runs every test with coverage |
coverage |
Exports the coverage report to your machine |
publish |
Publishes the Presentation project |
run |
The Lambda image you deploy |
docker build . --target coverage --output type=local,dest=outStamp a version
Section titled “Stamp a version”docker build . --target run --tag acme-reviews:latest \ --build-arg VERSION_PREFIX=1.2.3 --build-arg VERSION_SUFFIX=beta