Skip to content

Commit 770a572

Browse files
authored
Fix dependencies after applying operator sdk (argoproj-labs#1129)
Signed-off-by: Denis Karpelevich <[email protected]>
1 parent f067afe commit 770a572

File tree

8 files changed

+1016
-181
lines changed

8 files changed

+1016
-181
lines changed

Dockerfile

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
1-
# Build the manager binary
2-
FROM golang:1.22 AS builder
3-
ARG TARGETOS
4-
ARG TARGETARCH
5-
6-
WORKDIR /workspace
7-
# Copy the Go Modules manifests
8-
COPY go.mod go.mod
9-
COPY go.sum go.sum
10-
# cache deps before building and copying source so that we don't need to re-download as much
11-
# and so that source changes don't invalidate our downloaded layer
1+
FROM golang:1.23 AS builder
2+
3+
RUN mkdir -p /src/argocd-image-updater
4+
WORKDIR /src/argocd-image-updater
5+
# cache dependencies as a layer for faster rebuilds
6+
COPY go.mod go.sum ./
127
RUN go mod download
8+
COPY . .
9+
10+
RUN mkdir -p dist && \
11+
make controller
12+
13+
FROM alpine:3.21
14+
15+
RUN apk update && \
16+
apk upgrade && \
17+
apk add ca-certificates git openssh-client aws-cli tini gpg gpg-agent && \
18+
rm -rf /var/cache/apk/*
19+
20+
RUN mkdir -p /usr/local/bin
21+
RUN mkdir -p /app/config
22+
RUN adduser --home "/app" --disabled-password --uid 1000 argocd
23+
24+
COPY --from=builder /src/argocd-image-updater/dist/argocd-image-updater /usr/local/bin/
25+
COPY hack/git-ask-pass.sh /usr/local/bin/git-ask-pass.sh
26+
27+
USER 1000
1328

14-
# Copy the go source
15-
COPY cmd/main.go cmd/main.go
16-
COPY api/ api/
17-
COPY internal/controller/ internal/controller/
18-
19-
# Build
20-
# the GOARCH has not a default value to allow the binary be built according to the host where the command
21-
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
22-
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
23-
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
24-
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
25-
26-
# Use distroless as minimal base image to package the manager binary
27-
# Refer to https://github.com/GoogleContainerTools/distroless for more details
28-
FROM gcr.io/distroless/static:nonroot
29-
WORKDIR /
30-
COPY --from=builder /workspace/manager .
31-
USER 65532:65532
32-
33-
ENTRYPOINT ["/manager"]
29+
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/argocd-image-updater"]

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ endif
5050
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
5151
OPERATOR_SDK_VERSION ?= v1.39.2
5252
# Image URL to use all building/pushing image targets
53-
IMG ?= controller:latest
53+
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
5454
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5555
ENVTEST_K8S_VERSION = 1.31.0
5656

@@ -142,7 +142,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
142142
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
143143
.PHONY: docker-build
144144
docker-build: ## Build docker image with the manager.
145-
$(CONTAINER_TOOL) build -t ${IMG} .
145+
$(CONTAINER_TOOL) build -t ${IMG} -f controller.Dockerfile .
146146

147147
.PHONY: docker-push
148148
docker-push: ## Push docker image with the manager.

config/default/kustomization.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ resources:
3434
#- ../network-policy
3535

3636
# Uncomment the patches line if you enable Metrics, and/or are using webhooks and cert-manager
37-
patches:
37+
#patches:
3838
# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443.
3939
# More info: https://book.kubebuilder.io/reference/metrics
40-
- path: manager_metrics_patch.yaml
41-
target:
42-
kind: Deployment
40+
#- path: manager_metrics_patch.yaml
41+
# target:
42+
# kind: Deployment
4343

4444
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
4545
# crd/kustomization.yaml

config/manager/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
44
kind: Kustomization
55
images:
66
- name: controller
7-
newName: controller
8-
newTag: latest
7+
newName: argoproj.io/image-updater
8+
newTag: 0.0.1

config/manager/manager.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ spec:
6060
containers:
6161
- command:
6262
- /manager
63-
args:
64-
- --leader-elect
65-
- --health-probe-bind-address=:8081
63+
# args:
64+
# - --leader-elect
65+
# - --health-probe-bind-address=:8081
6666
image: controller:latest
6767
name: manager
6868
securityContext:

controller.Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Build the manager binary
2+
FROM golang:1.23.5 AS builder
3+
ARG TARGETOS
4+
ARG TARGETARCH
5+
6+
WORKDIR /workspace
7+
# Copy the Go Modules manifests
8+
COPY go.mod go.mod
9+
COPY go.sum go.sum
10+
# cache deps before building and copying source so that we don't need to re-download as much
11+
# and so that source changes don't invalidate our downloaded layer
12+
RUN go mod download
13+
14+
# Copy the go source
15+
COPY cmd/ cmd/
16+
COPY api/ api/
17+
COPY internal/controller/ internal/controller/
18+
COPY ext/ ext/
19+
COPY pkg/ pkg/
20+
21+
# Build
22+
# the GOARCH has not a default value to allow the binary be built according to the host where the command
23+
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
24+
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
25+
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
26+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager ./cmd
27+
28+
# Use distroless as minimal base image to package the manager binary
29+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
30+
FROM gcr.io/distroless/static:nonroot
31+
WORKDIR /
32+
COPY --from=builder /workspace/manager .
33+
USER 65532:65532
34+
35+
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)