forked from weaveworks/weave-gitops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitops.dockerfile
36 lines (28 loc) · 1006 Bytes
/
gitops.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
ARG FLUX_VERSION=0.24.1
ARG FLUX_CLI=ghcr.io/fluxcd/flux-cli:v$FLUX_VERSION
# Alias for flux
FROM $FLUX_CLI as flux
# Go build
FROM golang:1.20 AS go-build
# Add known_hosts entries for GitHub and GitLab
RUN mkdir ~/.ssh
RUN ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
COPY Makefile /app/
COPY tools /app/tools
WORKDIR /app
COPY go.* /app/
RUN go mod download
COPY . /app
# These are ARGS are defined here to minimise cache misses
# (cf. https://docs.docker.com/engine/reference/builder/#impact-on-build-caching)
# Pass these flags so we don't have to copy .git/ for those commands to work
ARG LDFLAGS="-X localbuild=true"
ARG GIT_COMMIT="_unset_"
RUN LDFLAGS=$LDFLAGS GIT_COMMIT=$GIT_COMMIT make gitops
# Distroless
FROM gcr.io/distroless/base as runtime
COPY --from=flux /usr/local/bin/flux /usr/local/bin/flux
COPY --from=go-build /app/bin/gitops /gitops
COPY --from=go-build /root/.ssh/known_hosts /root/.ssh/known_hosts
ENTRYPOINT ["/gitops"]