-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathDockerfile.controller
52 lines (35 loc) · 1.59 KB
/
Dockerfile.controller
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.19.5-bullseye AS builder
ENV DEBIAN_FRONTEND=noninteractive INSTALL_DIRECTORY=/usr/local/bin
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends git curl
WORKDIR /go/src/github.com/ibm/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
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build \
-ldflags "-X main.Version=$VERSION" \
-a \
-o varnish-controller \
./cmd/varnish-controller/
FROM --platform=$BUILDPLATFORM debian:bullseye-slim as binary
RUN apt-get update && apt-get install -y --no-install-recommends varnish
# Build Final Varnish image
FROM --platform=$BUILDPLATFORM debian:bullseye-slim
LABEL maintainer="Alex Lytvynenko <oleksandr.lytvynenko@ibm.com>, Tomash Sidei <tomash.sidei@ibm.com>"
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends libc6 libedit2 libncursesw6 libtinfo6 libvarnishapi2 \
&& rm -rf /var/lib/apt/lists/* \
/etc/varnish/* \
&& adduser --quiet --system --no-create-home --home /nonexistent --group varnish \
&& mkdir -p /etc/varnish /var/lib/varnish \
&& chown -R varnish /etc/varnish /var/lib/varnish
COPY --from=binary /usr/bin/varnishadm /usr/bin/varnishstat /usr/bin/
COPY --from=builder /go/src/github.com/ibm/varnish-operator/varnish-controller /varnish-controller
USER varnish
ENTRYPOINT ["/varnish-controller"]