Skip to content

Commit 1fab404

Browse files
committed
Simplify stuff
1 parent afaf4dc commit 1fab404

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

images/build/go-runner/Dockerfile

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,49 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# Get Go from official Alpine image
16+
ARG GO_VERSION
17+
FROM golang:${GO_VERSION}-alpine as go-source
18+
1519
# Build the manager binary
1620
ARG DISTROLESS_IMAGE
1721
ARG BUILDER_IMAGE
1822
FROM ${BUILDER_IMAGE} as builder
1923
WORKDIR /workspace
2024

21-
# Install dependencies for building Go from source
22-
RUN apt-get update && apt-get install -y \
23-
build-essential \
24-
curl \
25-
git \
26-
ca-certificates \
27-
&& rm -rf /var/lib/apt/lists/*
28-
29-
# Download and build Go from source
30-
ARG GO_VERSION
31-
32-
ARG TARGETARCH
33-
RUN echo "Determining bootstrap Go version for ${GO_VERSION}" && \
34-
BOOTSTRAP_GO_VERSION=$(curl -fsSL "https://raw.githubusercontent.com/golang/go/go${GO_VERSION}/src/make.bash" | grep "^bootgo=" | cut -d= -f2) && \
35-
echo "Installing bootstrap Go version: ${BOOTSTRAP_GO_VERSION} (${TARGETARCH})" && \
36-
GO_ARCH="${TARGETARCH}"; \
37-
if [ "${TARGETARCH}" = "arm" ]; then GO_ARCH="armv6l"; fi && \
38-
curl -fsSL "https://go.dev/dl/go${BOOTSTRAP_GO_VERSION}.linux-${GO_ARCH}.tar.gz" -o /tmp/go-bootstrap.tar.gz && \
39-
tar -xzf /tmp/go-bootstrap.tar.gz -C /usr/local && \
40-
mv /usr/local/go /usr/local/go-bootstrap && \
41-
rm /tmp/go-bootstrap.tar.gz
42-
43-
# Download Go source
44-
RUN echo "Downloading Go source version: ${GO_VERSION}" && \
45-
curl -fsSL "https://go.dev/dl/go${GO_VERSION}.src.tar.gz" -o /tmp/go.src.tar.gz && \
46-
tar -xzf /tmp/go.src.tar.gz -C /usr/local && \
47-
rm /tmp/go.src.tar.gz
48-
49-
# Build Go from source with bootstrap
50-
WORKDIR /usr/local/go/src
51-
ENV GOROOT_BOOTSTRAP=/usr/local/go-bootstrap
52-
RUN ./make.bash
25+
# Copy Go installation from official image
26+
COPY --from=go-source /usr/local/go /usr/local/go
5327

5428
# Set up Go environment
5529
ENV PATH=/usr/local/go/bin:$PATH
5630
ENV GOROOT=/usr/local/go
57-
ENV GOPATH=/workspace/gopath
5831

5932
# Copy the sources
6033
WORKDIR /workspace
@@ -90,6 +63,5 @@ FROM ${DISTROLESS_IMAGE}
9063
LABEL maintainers="Kubernetes Authors"
9164
LABEL description="go based runner for distroless scenarios"
9265
WORKDIR /
93-
COPY --from=builder /usr/local/go /usr/local/go
9466
COPY --from=builder /workspace/go-runner .
9567
ENTRYPOINT ["/go-runner"]

0 commit comments

Comments
 (0)