From ff25ba1e4172ffab2f9aefd592780c0840b36071 Mon Sep 17 00:00:00 2001 From: "Giau. Tran Minh" Date: Tue, 6 Feb 2024 10:33:08 +0700 Subject: [PATCH] operator: allow bundle atlas with given version --- .github/workflows/push-images.yaml | 9 ++++++++- Dockerfile | 18 +++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/push-images.yaml b/.github/workflows/push-images.yaml index 29974408..9992ad67 100644 --- a/.github/workflows/push-images.yaml +++ b/.github/workflows/push-images.yaml @@ -51,11 +51,18 @@ jobs: org.opencontainers.image.url=https://atlasgo.io org.opencontainers.image.vendor=Ariga org.opencontainers.image.source=https://github.com/ariga/atlas-operator/blob/master/Dockerfile + - name: Fetch Atlas version + id: atlas + run: | + # All distributions are built from the same version + # so we only need to fetch it once. + echo "::set-output name=version::$(curl -s https://release.ariga.io/atlas/atlas-linux-amd64-latest.version)" - name: Build and push uses: docker/build-push-action@v4 with: context: . build-args: | + ATLAS_VERSION=${{ steps.atlas.outputs.version }} OPERATOR_VERSION=v${{ steps.meta.outputs.version }} file: ./Dockerfile platforms: linux/amd64,linux/arm64 @@ -73,4 +80,4 @@ jobs: - name: Upload Trivy scan results to GitHub Security tab uses: github/codeql-action/upload-sarif@v2 with: - sarif_file: 'trivy-results.sarif' \ No newline at end of file + sarif_file: 'trivy-results.sarif' diff --git a/Dockerfile b/Dockerfile index e7c492e8..7ca08192 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ # limitations under the License. # Build the manager binary -FROM golang:1.21.5-alpine as builder +FROM golang:1.21.6-alpine3.19 as builder ARG TARGETOS ARG TARGETARCH ARG OPERATOR_VERSION @@ -37,16 +37,20 @@ COPY internal/ internal/ RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build \ - -ldflags "-X 'main.version=${OPERATOR_VERSION}'" \ - -a -o manager main.go + GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} CGO_ENABLED=0 \ + go build -ldflags "-X 'main.version=${OPERATOR_VERSION}'" \ + -o manager -a main.go -FROM arigaio/atlas:latest-alpine as atlas +FROM alpine:3.19 as atlas +RUN apk add --no-cache curl +ARG ATLAS_VERSION=latest +ENV ATLAS_VERSION=${ATLAS_VERSION} +RUN curl -sSf https://atlasgo.sh | sh -FROM alpine:3.19.0 +FROM alpine:3.19 WORKDIR / COPY --from=builder /workspace/manager . -COPY --from=atlas /atlas . +COPY --from=atlas /usr/local/bin/atlas . RUN chmod +x /atlas ENV ATLAS_NO_UPDATE_NOTIFIER=1 ENV ATLAS_KUBERNETES_OPERATOR=1