最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Error starting aws lambda using bootstrap script in a container - Stack Overflow

programmeradmin3浏览0评论

I am trying to follow the directions from tailscale's site here: so that I can connect from an AWS Lambda to a Tailscale network.

Here is docker file:

# ---- Build Stage ----
    FROM golang:1.24 AS builder
    WORKDIR /app
    COPY . ./
    
    # Build the Go binary with a different name
    RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /app/bootstrap-app main.go
    
    # ---- Production Stage ----
    FROM public.ecr.aws/lambda/provided:al2
    
    # Copy the compiled Go binary (renamed to avoid conflict with the script)
    COPY --from=builder /app/bootstrap-app /var/runtime/bootstrap-app
    RUN chmod +x /var/runtime/bootstrap-app  
    
    # Copy the bootstrap script (Lambda entrypoint)
    COPY bootstrap /var/runtime/bootstrap

    RUN chmod +x /var/runtime/bootstrap  

    
    # Copy Tailscale binaries from the official Tailscale image
    COPY --from=docker.io/tailscale/tailscale:stable /usr/local/bin/tailscaled /var/runtime/tailscaled
    COPY --from=docker.io/tailscale/tailscale:stable /usr/local/bin/tailscale /var/runtime/tailscale
    
    # Ensure necessary directories exist and symlink them to /tmp (since /var is read-only in Lambda)
    RUN mkdir -p /var/run && ln -s /tmp/tailscale /var/run/tailscale && \
        mkdir -p /var/cache && ln -s /tmp/tailscale /var/cache/tailscale && \
        mkdir -p /var/lib && ln -s /tmp/tailscale /var/lib/tailscale && \
        mkdir -p /var/task && ln -s /tmp/tailscale /var/task/tailscale
    
    # Set execute permissions on all necessary files
    RUN chmod +x /var/runtime/bootstrap /var/runtime/bootstrap-app /var/runtime/tailscale /var/runtime/tailscaled
    
    # Define the entrypoint to use the bootstrap script

    ENTRYPOINT ["/var/runtime/bootstrap"]
    

Here is my bootstrap file:

#!/bin/sh

mkdir -p /tmp/tailscale
/var/runtime/tailscaled --tun=userspace-networking --socks5-server=localhost:1055 &
/var/runtime/tailscale up --auth-key=${tskey} --hostname=mfalling-container-app
echo Tailscale started
ALL_PROXY=socks5://localhost:1055/ /var/runtime/bootstrap-app

No matter what I do, I get this in the Lambda logs upon start: { "errorType": "Runtime.InvalidEntrypoint", "errorMessage": "RequestId: b88da6ca-a770-407c-87f8-061449b41702 Error: fork/exec /var/runtime/bootstrap: exec format error" }

When I run the go binary by itself as a zip, it works fine. I can even put it in a container and that's fine (as long as it's called bootstrap). But an executable script just will not work for me.

发布评论

评论列表(0)

  1. 暂无评论