-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.lambda
More file actions
71 lines (55 loc) · 2.31 KB
/
Copy pathDockerfile.lambda
File metadata and controls
71 lines (55 loc) · 2.31 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# ==============================================================================
# Build Stage
# ==============================================================================
ARG GO_VERSION=1.25-alpine
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS builder
ARG VERSION=dev
ARG GIT_COMMIT=none
ARG BUILD_DATE=unknown
ARG TARGETOS
ARG TARGETARCH
RUN apk update && apk add --no-cache \
git \
ca-certificates \
tzdata \
&& update-ca-certificates
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
# Compile static binary with optimizations and metadata injection
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
go build -trimpath \
-ldflags="-s -w \
-X github.com/divmora/owlflow/pkg/version.Version=${VERSION} \
-X github.com/divmora/owlflow/pkg/version.GitCommit=${GIT_COMMIT} \
-X github.com/divmora/owlflow/pkg/version.BuildDate=${BUILD_DATE}" \
-o /build/owlflow ./cmd/server
# ==============================================================================
# Final AWS Lambda Runtime Stage (with AWS Lambda Web Adapter)
# ==============================================================================
FROM alpine:3.24 AS final
# Install runtime dependencies (certificates, timezone data)
RUN apk update && apk add --no-cache \
ca-certificates \
tzdata \
&& rm -rf /var/cache/apk/*
# Install AWS Lambda Web Adapter (intercepts Lambda invocations and proxies to HTTP PORT 8080)
COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.8.4 /lambda-adapter /opt/extensions/lambda-adapter
WORKDIR /app
# Copy compiled binary
COPY --from=builder /build/owlflow /app/owlflow
# Copy configurations
COPY --from=builder /src/configs /app/configs
LABEL org.opencontainers.image.title="owlflow-lambda" \
org.opencontainers.image.description="AWS Lambda container runtime for OwlFlow automation engine" \
org.opencontainers.image.url="https://github.com/divmora/owlflow" \
org.opencontainers.image.source="https://github.com/divmora/owlflow" \
org.opencontainers.image.vendor="divmora" \
org.opencontainers.image.licenses="BSL-1.1"
# AWS Lambda Web Adapter proxy settings
ENV PORT=8080 \
AWS_LWA_INVOKE_MODE=buffered \
SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
EXPOSE 8080
CMD ["/app/owlflow"]