From 7350fca5135000456b97ad6eb64e703e7ab2ecba Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Fri, 23 May 2025 12:26:41 +1000 Subject: [PATCH 1/4] feat(.github/workflows): Build docker images for graviton instances --- .github/workflows/release-please.yaml | 1 - .github/workflows/test.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index 55ed3e4..3034536 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -76,6 +76,5 @@ jobs: docker-context: "." docker-tag: "${{ needs.release-please.outputs.server-version }}" docker-tag-latest: true - docker-image-platforms: linux/amd64 docker-repository: "610829907584.dkr.ecr.ap-southeast-2.amazonaws.com/gitops" command: echo $SECRET_ENV | base64 -d > cluster.key diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 51b5a72..a4c092d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,6 +36,5 @@ jobs: docker-context: "." docker-prefix: test docker-tag-latest: false - docker-image-platforms: linux/amd64 docker-repository: "610829907584.dkr.ecr.ap-southeast-2.amazonaws.com/gitops" command: echo $SECRET_ENV | base64 -d > cluster.key From d2ae1e31723c66bbeb91020b94e949a808e1e304 Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Fri, 23 May 2025 15:36:58 +1000 Subject: [PATCH 2/4] chore(Dockerfile): Fix Dockerfile --- Dockerfile | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index c8be3c2..0fdd1c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,32 +3,42 @@ FROM python:3.12-slim ## ## Install kubectl and dependencies. ## -# RUN apk add -U openssl curl tar gzip bash ca-certificates && \ -# wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub && \ -# wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.23-r3/glibc-2.23-r3.apk && \ -# apk add glibc-2.23-r3.apk && \ -# rm glibc-2.23-r3.apk -# RUN curl -L -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/linux/amd64/kubectl && \ -# chmod +x /usr/bin/kubectl && \ -# kubectl version --client ENV KUBE_LATEST_VERSION="v1.21.3" ENV HELM_VERSION="v3.6.2" \ VIRTUAL_ENV="/app/.venv" \ PATH="/app/.venv/bin:$PATH" -RUN apt-get update -RUN apt-get install wget ca-certificates bash git git-crypt -y --no-install-recommends \ - && wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/amd64/kubectl -O /usr/local/bin/kubectl \ +ENV TARGETARCH="" + +RUN apt-get update \ + && apt-get install wget ca-certificates bash git git-crypt -y --no-install-recommends \ + # Determine target architecture and set TARGETARCH accordingly + && case "$(dpkg --print-architecture)" in \ + amd64) export TARGETARCH="amd64" ;; \ + arm64) export TARGETARCH="arm64" ;; \ + *) echo "Unsupported architecture: $(dpkg --print-architecture)"; exit 1 ;; \ + esac \ + \ + # Download kubectl + && wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/${TARGETARCH}/kubectl -O /usr/local/bin/kubectl \ && chmod +x /usr/local/bin/kubectl \ - && wget -q https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz -O - | tar -xzO linux-amd64/helm > /usr/local/bin/helm \ + \ + # Download helm + && wget -q https://get.helm.sh/helm-${HELM_VERSION}-linux-${TARGETARCH}.tar.gz -O - | tar -xzO linux-${TARGETARCH}/helm > /usr/local/bin/helm \ && chmod +x /usr/local/bin/helm \ + \ + # Install helm-secrets plugin && helm plugin install https://github.com/jkroepke/helm-secrets --version v4.2.2 \ - && wget -q https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux.amd64 -O /usr/local/bin/sops \ + \ + # Download sops + && wget -q https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux.${TARGETARCH} -O /usr/local/bin/sops \ && chmod +x /usr/local/bin/sops \ + \ && apt-get clean \ && apt-get -y autoremove \ && rm -rf /var/lib/apt/lists/* \ - && rm -rf /var/cache/apt/ \ - ENV SHELL=/bin/bash + && rm -rf /var/cache/apt/ + +ENV SHELL=/bin/bash ## ## Install dependencies and copy GitOps server. @@ -49,5 +59,4 @@ ENV GIT_CRYPT_KEY_FILE=/app/cluster.key ENV PYTHONPATH="$PYTHONPATH:/app" ENV ACCESS_LOG="" - -CMD ["uvicorn", "--host", "0.0.0.0", "--port", "8000", "gitops_server.main:app"] +CMD ["uvicorn", "--host", "0.0.0.0", "--port", "8000", "gitops_server.main:app"] \ No newline at end of file From 3467b48d9e599e55327c2dc3a3cc3e223017f534 Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Tue, 27 May 2025 10:21:10 +1000 Subject: [PATCH 3/4] chore(dockerfile): Use existing TARGETPLATFORM arg --- Dockerfile | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0fdd1c6..71d8904 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM python:3.12-slim +ARG TARGETPLATFORM + ## ## Install kubectl and dependencies. ## @@ -7,30 +9,23 @@ ENV KUBE_LATEST_VERSION="v1.21.3" ENV HELM_VERSION="v3.6.2" \ VIRTUAL_ENV="/app/.venv" \ PATH="/app/.venv/bin:$PATH" -ENV TARGETARCH="" + RUN apt-get update \ && apt-get install wget ca-certificates bash git git-crypt -y --no-install-recommends \ - # Determine target architecture and set TARGETARCH accordingly - && case "$(dpkg --print-architecture)" in \ - amd64) export TARGETARCH="amd64" ;; \ - arm64) export TARGETARCH="arm64" ;; \ - *) echo "Unsupported architecture: $(dpkg --print-architecture)"; exit 1 ;; \ - esac \ - \ # Download kubectl - && wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/${TARGETARCH}/kubectl -O /usr/local/bin/kubectl \ + && wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/${TARGETPLATFORM}/kubectl -O /usr/local/bin/kubectl \ && chmod +x /usr/local/bin/kubectl \ \ # Download helm - && wget -q https://get.helm.sh/helm-${HELM_VERSION}-linux-${TARGETARCH}.tar.gz -O - | tar -xzO linux-${TARGETARCH}/helm > /usr/local/bin/helm \ + && wget -q https://get.helm.sh/helm-${HELM_VERSION}-linux-${TARGETPLATFORM}.tar.gz -O - | tar -xzO linux-${TARGETPLATFORM}/helm > /usr/local/bin/helm \ && chmod +x /usr/local/bin/helm \ \ # Install helm-secrets plugin && helm plugin install https://github.com/jkroepke/helm-secrets --version v4.2.2 \ \ # Download sops - && wget -q https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux.${TARGETARCH} -O /usr/local/bin/sops \ + && wget -q https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux.${TARGETPLATFORM} -O /usr/local/bin/sops \ && chmod +x /usr/local/bin/sops \ \ && apt-get clean \ From 9bcdc7250dabba43e4be5e5bc6ffc0a49be837e9 Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Tue, 27 May 2025 10:22:50 +1000 Subject: [PATCH 4/4] chore(dockerfile): Use existing TARGETARCH arg --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 71d8904..5a1fbea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.12-slim -ARG TARGETPLATFORM +ARG TARGETARCH ## ## Install kubectl and dependencies. @@ -14,18 +14,18 @@ ENV HELM_VERSION="v3.6.2" \ RUN apt-get update \ && apt-get install wget ca-certificates bash git git-crypt -y --no-install-recommends \ # Download kubectl - && wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/${TARGETPLATFORM}/kubectl -O /usr/local/bin/kubectl \ + && wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/${TARGETARCH}/kubectl -O /usr/local/bin/kubectl \ && chmod +x /usr/local/bin/kubectl \ \ # Download helm - && wget -q https://get.helm.sh/helm-${HELM_VERSION}-linux-${TARGETPLATFORM}.tar.gz -O - | tar -xzO linux-${TARGETPLATFORM}/helm > /usr/local/bin/helm \ + && wget -q https://get.helm.sh/helm-${HELM_VERSION}-linux-${TARGETARCH}.tar.gz -O - | tar -xzO linux-${TARGETARCH}/helm > /usr/local/bin/helm \ && chmod +x /usr/local/bin/helm \ \ # Install helm-secrets plugin && helm plugin install https://github.com/jkroepke/helm-secrets --version v4.2.2 \ \ # Download sops - && wget -q https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux.${TARGETPLATFORM} -O /usr/local/bin/sops \ + && wget -q https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux.${TARGETARCH} -O /usr/local/bin/sops \ && chmod +x /usr/local/bin/sops \ \ && apt-get clean \