-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
27 lines (19 loc) · 819 Bytes
/
Copy pathDockerfile
File metadata and controls
27 lines (19 loc) · 819 Bytes
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
FROM golang:1.23 AS builder
WORKDIR /app
# Copy go.mod and go.sum first to leverage Docker cache
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source code
COPY . .
# Argument to select which function to build (default to generate)
ARG FUNCTION=generate
# Build the binary
# GOOS=linux GOARCH=amd64 is required for the Lambda execution environment
RUN GOOS=linux GOARCH=amd64 go build -o bootstrap internal/adapters/functions/${FUNCTION}/main.go
# Stage 2: AWS Lambda Runtime
FROM public.ecr.aws/lambda/provided:al2023
# Copy the compiled binary from the builder stage
# The lambda runtime expects the executable to be located at ${LAMBDA_RUNTIME_DIR}/bootstrap
COPY --from=builder /app/bootstrap ${LAMBDA_RUNTIME_DIR}/bootstrap
# Set the command to run the bootstrap file
CMD [ "bootstrap" ]