Rewrote IMDS emulator in Go, added unit tests.
This commit is contained in:
1 parent
cedac0a6ee
commit
630375c7ed
10 files changed
+940
-248
No files matched your search
+10
-9
@@ -1,13 +1,14 @@
|
||||
FROM python:3.13-slim-trixie AS build
|
||||
FROM golang:1.27-trixie AS build
|
||||
|
||||
# The interpreter path in the virtualenv must match the path in the distroless image.
|
||||
RUN ln -s /usr/local/bin/python /usr/bin/python \
|
||||
&& /usr/bin/python -m venv /venv \
|
||||
&& /venv/bin/pip install --no-cache-dir "google-auth[requests,cryptography]>=2.39.0"
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY main.go main_test.go ./
|
||||
RUN CGO_ENABLED=0 go test ./... \
|
||||
&& CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /imds-emulator .
|
||||
|
||||
FROM gcr.io/distroless/python3-debian13
|
||||
FROM gcr.io/distroless/static-debian13
|
||||
|
||||
COPY --from=build /venv /venv
|
||||
COPY imds_emulator.py imds_test.py /app/
|
||||
COPY --from=build /imds-emulator /imds-emulator
|
||||
|
||||
ENTRYPOINT ["/venv/bin/python3", "/app/imds_emulator.py"]
|
||||
ENTRYPOINT ["/imds-emulator"]
|
||||
Reference in new issue
Block a user