Skip to content

Commit

Permalink
operator: allow bundle atlas with given version
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm committed Feb 6, 2024
1 parent 0baf768 commit 4c823a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/push-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Fetch Atlas version
id: atlas
run: |
# All distributions are built from the same version
# so we only need to fetch it once.
echo "version=$(curl -s https://release.ariga.io/atlas/atlas-linux-amd64-latest.version)" >> $GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
Expand All @@ -51,11 +57,13 @@ 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
io.ariga.atlas.version=${{ steps.atlas.outputs.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
Expand All @@ -73,4 +81,4 @@ jobs:
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
sarif_file: 'trivy-results.sarif'
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4c823a4

Please sign in to comment.