-
Notifications
You must be signed in to change notification settings - Fork 3
/
DockerfileRouter
47 lines (34 loc) · 1.45 KB
/
DockerfileRouter
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
# Set the working directory
WORKDIR /app
# Copy just files needed for dotnet restore
COPY *.sln ./
COPY src/PwrDrvr.LambdaDispatch.Router/PwrDrvr.LambdaDispatch.Router.csproj ./src/PwrDrvr.LambdaDispatch.Router/
COPY src/PwrDrvr.LambdaDispatch.Messages/PwrDrvr.LambdaDispatch.Messages.csproj ./src/PwrDrvr.LambdaDispatch.Messages/
# Restore dependencies
RUN dotnet restore src/PwrDrvr.LambdaDispatch.Router/PwrDrvr.LambdaDispatch.Router.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.Router/PwrDrvr.LambdaDispatch.Router.csproj -c Release --self-contained true --runtime $BUILD_ARCH -o out
# Use the Amazon Linux 2023 image as the runtime environment
# Use the runtime image for ARM64
FROM amazonlinux:2023
# Declare the build argument with a default value
ARG GIT_HASH=none
ARG BUILD_TIME=none
# Set the environment variable
ENV GIT_HASH=$GIT_HASH
ENV BUILD_TIME=$BUILD_TIME
# Set the working directory
WORKDIR /app
# Install the ICU libraries
RUN yum install -y libicu
# Copy the build output from the build environment
COPY --from=build-env /app/out .
COPY --from=build-env /app/certs/*.pfx ./certs/
# Set the entrypoint
ENTRYPOINT ["./PwrDrvr.LambdaDispatch.Router"]