This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
56 lines (41 loc) · 1.47 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
53
54
55
56
# Build the manager binary
FROM golang:1.20 as builder
ARG TARGETARCH
ARG BUILD_SHA
ARG BUILD_VERSION
RUN apt-get update && apt-get install -y unzip
WORKDIR /workspace
# Copy API and its Go module
COPY api/ api/
# Copy tfctl and its Go module
COPY tfctl/ tfctl/
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY cmd/manager/main.go cmd/manager/main.go
COPY controllers/ controllers/
COPY mtls/ mtls/
COPY runner/ runner/
COPY utils/ utils/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} \
go build -gcflags=all="-N -l" \
-ldflags "-X main.BuildSHA='${BUILD_SHA}' -X main.BuildVersion='${BUILD_VERSION}'" \
-a -o tf-controller cmd/manager/main.go
FROM alpine:3.18
LABEL org.opencontainers.image.source="https://github.com/weaveworks/tf-controller"
RUN apk update
RUN apk add --no-cache libcrypto3=3.1.2-r0 && \
apk add --no-cache libssl3=3.1.2-r0 && \
apk add --no-cache ca-certificates tini git openssh-client gnupg && \
apk add --no-cache libretls && \
apk add --no-cache busybox
COPY --from=builder /workspace/tf-controller /usr/local/bin/
RUN addgroup --gid 65532 -S controller && adduser --uid 65532 -S controller -G controller
USER 65532:65532
ENV GNUPGHOME=/tmp
ENTRYPOINT [ "/sbin/tini", "--", "tf-controller" ]