-
Notifications
You must be signed in to change notification settings - Fork 139
/
Copy pathDockerfile.utils
45 lines (30 loc) · 1.16 KB
/
Dockerfile.utils
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
FROM scratch AS builder
ARG BUILDPLATFORM
ARG BUILDARCH
ARG TARGETPLATFORM
ARG TARGETARCH
ADD .artifacts/alpine-minirootfs-$BUILDARCH.tar.gz /
COPY .artifacts/go.tar.gz /tmp/go.tar.gz
RUN tar -C /usr/local -xzf /tmp/go.tar.gz
ENV PATH="/usr/local/go/bin:$PATH"
WORKDIR /workspace
COPY go.mod go.sum ./
RUN go mod download -x
COPY . .
RUN GOARCH=$TARGETARCH go build -o func-util -trimpath -ldflags '-w -s' ./cmd/func-util
#########################
FROM scratch
ARG TARGETARCH
ADD .artifacts/alpine-minirootfs-$TARGETARCH.tar.gz /
RUN apk add --no-cache tar
COPY --from=builder /workspace/func-util /usr/local/bin/
RUN ln -s /usr/local/bin/func-util /usr/local/bin/deploy && \
ln -s /usr/local/bin/func-util /usr/local/bin/scaffold && \
ln -s /usr/local/bin/func-util /usr/local/bin/s2i && \
ln -s /usr/local/bin/func-util /usr/local/bin/socat
LABEL \
org.opencontainers.image.description="Knative Func Utils Image" \
org.opencontainers.image.source="https://github.com/knative/func" \
org.opencontainers.image.vendor="https://github.com/knative/func" \
org.opencontainers.image.url="https://github.com/knative/func/pkgs/container/func-utils"
USER 0:0