1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/cmd/cli/kubectl-kyverno/Dockerfile
James Callahan 975a2a21fa
fix: use an absolute path in docker entrypoint (#4263)
With a relative path, containers started with a different working
directory will fail to find the entrypoint

Fixes: #4252
Signed-off-by: James Callahan <jamescallahan@bitgo.com>

Co-authored-by: shuting <shuting@nirmata.com>
2022-07-26 07:16:01 +00:00

34 lines
957 B
Docker

# Multi-stage docker build
# Build stage
FROM --platform=${BUILDPLATFORM} golang@sha256:724abf4dd44985d060f7aa91af5211eb2052491424bd497ba3ddc31f7cee969d AS base
WORKDIR /src
LABEL maintainer="Kyverno"
COPY go.* .
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
FROM --platform=${BUILDPLATFORM} tonistiigi/xx:1.1.1@sha256:23ca08d120366b31d1d7fad29283181f063b0b43879e1f93c045ca5b548868e9 AS xx
FROM base AS builder
# LD_FLAGS is passed as argument from Makefile. It will be empty, if no argument passed
ARG LD_FLAGS
ARG TARGETPLATFORM
COPY --from=xx / /
RUN --mount=type=bind,target=. \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 xx-go build -o /output/kyverno -ldflags="${LD_FLAGS}" -v ./cmd/cli/kubectl-kyverno/
# Packaging stage
FROM ghcr.io/distroless/static:latest
LABEL maintainer="Kyverno"
COPY --from=builder /output/kyverno /
ENTRYPOINT ["/kyverno"]