forked from IBM/varnish-operator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
52 lines (34 loc) · 1.23 KB
/
Dockerfile
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
46
47
48
49
50
51
52
ARG BUILDPLATFORM=linux/amd64
FROM --platform=$BUILDPLATFORM golang:1.20-bullseye AS builder
ENV DEBIAN_FRONTEND=noninteractive INSTALL_DIRECTORY=/usr/local/bin
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /go/src/github.com/cin/varnish-operator
ENV GOPROXY=https://proxy.golang.org
COPY go.mod go.sum ./
RUN go mod download
COPY cmd/ cmd/
COPY pkg/ pkg/
COPY api/ api/
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG VERSION=undefined
# Build
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build \
-ldflags "-X main.Version=$VERSION" \
-a \
-o varnish-operator \
github.com/cin/varnish-operator/cmd/varnish-operator
FROM --platform=$BUILDPLATFORM debian:bullseye-slim
LABEL maintainer="Alex Lytvynenko <[email protected]>, Tomash Sidei <[email protected]>"
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /
RUN apt-get update && apt-get upgrade -y \
&& rm -rf /var/lib/apt/lists/*
RUN addgroup --gid 901 varnish-operator && adduser --uid 901 --gid 901 varnish-operator
COPY --from=builder /go/src/github.com/cin/varnish-operator/varnish-operator .
USER varnish-operator
ENTRYPOINT ["/varnish-operator"]