From 3518a076e7e4db060c13b34749402ff91a9ef920 Mon Sep 17 00:00:00 2001 From: Jonah Back Date: Wed, 20 Jan 2021 21:52:36 -0800 Subject: [PATCH 1/2] feat: add x-arch builds for arm64 and amd64, remove assumption of running on amd64 Signed-off-by: Jonah Back --- Dockerfile | 6 ++++-- server/server.go | 14 +++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5ff315ff0ef2d..d193222380de6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -122,7 +122,9 @@ RUN make argocd-all ARG BUILD_ALL_CLIS=true RUN if [ "$BUILD_ALL_CLIS" = "true" ] ; then \ make BIN_NAME=argocd-darwin-amd64 GOOS=darwin argocd-all && \ - make BIN_NAME=argocd-windows-amd64.exe GOOS=windows argocd-all \ + make BIN_NAME=argocd-windows-amd64.exe GOOS=windows argocd-all && \ + make BIN_NAME=argocd-linux-amd64 GOOS=linux GOARCH=amd64 argocd-all && \ + make BIN_NAME=argocd-linux-arm64 GOOS=linux GOARCH=arm64 argocd-all \ ; fi #################################################################################################### @@ -139,4 +141,4 @@ RUN ln -s /usr/local/bin/argocd /usr/local/bin/argocd-repo-server RUN ln -s /usr/local/bin/argocd /usr/local/bin/argocd-application-controller RUN ln -s /usr/local/bin/argocd /usr/local/bin/argocd-dex -USER 999 \ No newline at end of file +USER 999 diff --git a/server/server.go b/server/server.go index e93b5e697b9cd..4d6fb1f2ab209 100644 --- a/server/server.go +++ b/server/server.go @@ -755,12 +755,20 @@ func newRedirectServer(port int, rootPath string) *http.Server { // registerDownloadHandlers registers HTTP handlers to support downloads directly from the API server // (e.g. argocd CLI) func registerDownloadHandlers(mux *http.ServeMux, base string) { - linuxPath, err := exec.LookPath("argocd") + linuxAmdPath, err := exec.LookPath("argocd-linux-amd64") if err != nil { - log.Warnf("argocd not in PATH") + log.Warnf("argocd-linux-amd64 not in PATH") } else { mux.HandleFunc(base+"/argocd-linux-amd64", func(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, linuxPath) + http.ServeFile(w, r, linuxAmdPath) + }) + } + linuxArmPath, err := exec.LookPath("argocd-linux-arm64") + if err != nil { + log.Warnf("argocd-linux-arm64 not in PATH") + } else { + mux.HandleFunc(base+"/argocd-linux-arm64", func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, linuxArmPath) }) } darwinPath, err := exec.LookPath("argocd-darwin-amd64") From 1ccbc171f55a2c07fe1186dddc645c9a204e1197 Mon Sep 17 00:00:00 2001 From: Jonah Back Date: Mon, 25 Jan 2021 10:07:52 -0800 Subject: [PATCH 2/2] Use symlink and file to avoid duplicating binary in container image Signed-off-by: Jonah Back --- Dockerfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d193222380de6..45bb628f1dff8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -117,14 +117,16 @@ RUN go mod download # Perform the build COPY . . -RUN make argocd-all ARG BUILD_ALL_CLIS=true RUN if [ "$BUILD_ALL_CLIS" = "true" ] ; then \ make BIN_NAME=argocd-darwin-amd64 GOOS=darwin argocd-all && \ make BIN_NAME=argocd-windows-amd64.exe GOOS=windows argocd-all && \ make BIN_NAME=argocd-linux-amd64 GOOS=linux GOARCH=amd64 argocd-all && \ - make BIN_NAME=argocd-linux-arm64 GOOS=linux GOARCH=arm64 argocd-all \ + make BIN_NAME=argocd-linux-arm64 GOOS=linux GOARCH=arm64 argocd-all && \ + cd dist && echo $(go env GOARCH) > argocd-arch \ + ; else \ + make argocd-all \ ; fi #################################################################################################### @@ -135,6 +137,10 @@ COPY --from=argocd-build /go/src/github.com/argoproj/argo-cd/dist/argocd* /usr/l COPY --from=argocd-ui ./src/dist/app /shared/app USER root +ARG BUILD_ALL_CLIS=true +RUN if [ "$BUILD_ALL_CLIS" = "true" ] ; then \ + CPU_ARCH=$(cat /usr/local/bin/argocd-arch) && ln -s /usr/local/bin/argocd-linux-$CPU_ARCH /usr/local/bin/argocd \ + ; fi RUN ln -s /usr/local/bin/argocd /usr/local/bin/argocd-util RUN ln -s /usr/local/bin/argocd /usr/local/bin/argocd-server RUN ln -s /usr/local/bin/argocd /usr/local/bin/argocd-repo-server