Skip to content

Commit

Permalink
Merge pull request #6 from justinsb/build_minimal
Browse files Browse the repository at this point in the history
chore: create script to build etcd-manager-minimal image
  • Loading branch information
k8s-ci-robot authored Sep 1, 2024
2 parents 27f3fa7 + be0d1ae commit 7bef1bc
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
36 changes: 36 additions & 0 deletions dev/tasks/build-images
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
#
# Copyright 2024 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "${REPO_ROOT}"

if [[ -z "${IMAGE_PREFIX:-}" ]]; then
echo "IMAGE_PREFIX is not set"
exit 1
fi

IMAGE_TAG=${IMAGE_PREFIX}/etcd-manager-minimal:latest

if [[ -z "${BUILD_ARGS:-}" ]]; then
BUILD_ARGS="--load"
fi
echo "Building image ${IMAGE_TAG} with args ${BUILD_ARGS:-}"

docker buildx build ${BUILD_ARGS} -t ${IMAGE_TAG} -f ./images/etcd-manager-minimal/Dockerfile .
23 changes: 23 additions & 0 deletions images/etcd-manager-minimal/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.22 AS builder

RUN mkdir /workspace
WORKDIR /workspace
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
RUN CGO_ENABLED=0 go build k8s.io/klog/v2 go.etcd.io/etcd/client/v3

COPY cmd cmd
COPY pkg pkg


RUN CGO_ENABLED=0 go build -v -o /etcd-manager ./cmd/etcd-manager

#FROM scratch
# We at least need debian12 for sh, becaue we currently launch with a shell for log files
#FROM gcr.io/distroless/static-debian12:latest
FROM debian:12

COPY --from=builder /etcd-manager /etcd-manager

ENTRYPOINT [ "/etcd-manager" ]

0 comments on commit 7bef1bc

Please sign in to comment.