-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (39 loc) · 1.22 KB
/
Dockerfile
File metadata and controls
51 lines (39 loc) · 1.22 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
#syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.6.1 AS xx
FROM --platform=$BUILDPLATFORM golang:1.24.1-alpine as builder
WORKDIR /app
COPY --from=xx / /
COPY go.mod go.sum ./
RUN go mod download
COPY cmd cmd
COPY internal internal
COPY *.go ./
# Set Golang build envs based on Docker platform string
ARG TARGETPLATFORM
RUN --mount=type=cache,target=/root/.cache \
CGO_ENABLED=0 xx-go build -ldflags='-w -s' -tags lambda.norpc -trimpath -o cloudwatch-slack-alerts .
FROM alpine:3.21 AS rie
WORKDIR /app
ARG TARGETPLATFORM
ARG RIE_VERSION=v1.23
RUN <<EOT
set -eux
case "$TARGETPLATFORM" in
'linux/amd64') export SUFFIX=x86_64 ;;
'linux/arm64') export SUFFIX=arm64 ;;
*) echo "Unsupported target: $TARGETPLATFORM" && exit 1 ;;
esac
wget \
-O aws-lambda-rie \
"https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/download/$RIE_VERSION/aws-lambda-rie-$SUFFIX"
chmod +x aws-lambda-rie
EOT
FROM gcr.io/distroless/static:nonroot AS base
WORKDIR /
COPY --from=builder /app/cloudwatch-slack-alerts .
ENTRYPOINT ["./cloudwatch-slack-alerts"]
FROM base AS local
COPY --from=rie /app/aws-lambda-rie .
ENTRYPOINT ["./aws-lambda-rie"]
CMD ["./cloudwatch-slack-alerts"]
FROM base