n-daisuke-blog-deployment-s.../docker/Dockerfile

18 lines
No EOL
686 B
Docker

FROM docker.io/golang:1.25.5-bookworm as build
WORKDIR /app
# NOTE: This Dockerfile assumes the build context is the repository root.
# Example: docker build -f docker/Dockerfile .
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Build with optional lambda.norpc tag for arm64 architecture
RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -tags lambda.norpc -o main ./cmd/lambda
# Copy artifacts to a clean image
FROM public.ecr.aws/lambda/provided:al2023
# Install git and zip using dnf (Amazon Linux 2023)
RUN dnf update -y && \
dnf install -y git zip && \
dnf clean all
COPY --from=build /app/main ${LAMBDA_TASK_ROOT}
WORKDIR ${LAMBDA_TASK_ROOT}
ENTRYPOINT [ "./main" ]