GoogleContainerTools / distroless

🥑 Language focused docker images, minus the operating system.
Apache License 2.0
18.69k stars 1.14k forks source link

Trying to COPY GNU binary into the image disappears #1672

Closed Skarlso closed 5 days ago

Skarlso commented 5 days ago

Describe the bug Trying to build this dockerfile:

# Use the official Golang image to create a build artifact.
FROM golang:1.23 as builder

# Set the Current Working Directory inside the container
WORKDIR /go/src/app
COPY . .

RUN go mod download

RUN CGO_ENABLED=0 go build -o /go/bin/app

# Install pg_dump by installing postgresql-client
RUN apt-get update && apt-get install -y --no-install-recommends postgresql-client && \
    rm -rf /var/lib/apt/lists/*

# Start a new stage from scratch
FROM gcr.io/distroless/static-debian11

# Copy the Pre-built binary file from the previous stage
COPY --from=builder /go/bin/app /
COPY --from=builder /go/src/app/local_manifest.yaml /
# Copy the pg_dump binary and necessary libraries from the first stage
COPY --from=builder /usr/bin/pg_dump /
COPY --from=builder /lib/x86_64-linux-gnu /lib/x86_64-linux-gnu

# Debug
COPY --from=builder /bin/sh /bin/sh

# Expose port 8080 to the outside world
EXPOSE 8080

# Command to run the executable
ENTRYPOINT ["/app"]

None of the things are there. Like /bin/sh or pg_dump none of them are there. app IS there. So I don't really understand what's going on here?

To Reproduce Steps to reproduce the behavior:

Expected behavior A clear and concise description of what you expected to happen.

Console Output If applicable, add information from your container run

Additional context Add any other context about the problem here.

Skarlso commented 5 days ago

Nevermind. It was there. It was actually complaining about the environment missing perl and env.