-
Notifications
You must be signed in to change notification settings - Fork 3
/
DockerfileExtensionDotNet
47 lines (36 loc) · 1.72 KB
/
DockerfileExtensionDotNet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Use the official .NET 8 SDK image as the build environment
# Build with whatever CPU the host OS has
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
# Needed for Native AOT compilation
RUN apt update
RUN apt install -y clang zlib1g-dev libssl-dev cmake
# Set the working directory
WORKDIR /app
# Copy just files needed for dotnet restore
COPY *.sln ./
COPY src/PwrDrvr.LambdaDispatch.Extension/PwrDrvr.LambdaDispatch.Extension.csproj ./src/PwrDrvr.LambdaDispatch.Extension/
COPY src/PwrDrvr.LambdaDispatch.Messages/PwrDrvr.LambdaDispatch.Messages.csproj ./src/PwrDrvr.LambdaDispatch.Messages/
# Restore dependencies
RUN dotnet restore src/PwrDrvr.LambdaDispatch.Extension/PwrDrvr.LambdaDispatch.Extension.csproj
# Copy everything from the current directory to the working directory in the image
COPY . ./
# Build the project
ARG BUILD_ARCH=linux-arm64
RUN dotnet publish src/PwrDrvr.LambdaDispatch.Extension/PwrDrvr.LambdaDispatch.Extension.csproj -c Release --self-contained true --runtime $BUILD_ARCH -o out /p:NativeAot=true
# We do not need the ~40 MB of ICU libs
RUN rm out/libicu* || true
#
# Runtime image for the extension
# This exec and entrypoint can be copied to another Lambda base image that
# already includes a language runtime (e.g. for Node.js, DotNet, etc.)
#
# The bootstrap exec is statically linked and does not depend on any shared
# libraries. It is built with the same CPU architecture as the host OS.
# It should run and invoke the `./bootstrap.sh` shell script
# which will start the desired app, such as `exec node index.js`.
#
FROM public.ecr.aws/lambda/provided:al2023
# Copy the bootstrap executable
COPY --from=build-env /app/out/bootstrap /lambda-dispatch
# Set the entrypoint
ENTRYPOINT ["/lambda-dispatch"]