Skip to content

Commit

Permalink
[RayJob][Feature] move light weight job submitter to a dedicated image
Browse files Browse the repository at this point in the history
Signed-off-by: Rueian <[email protected]>
  • Loading branch information
rueian committed Dec 10, 2024
1 parent a43cc3a commit d274346
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 3 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/image-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,101 @@ jobs:
ref: 'refs/tags/ray-operator/${{ github.event.inputs.tag }}',
sha: '${{ github.event.inputs.commit }}'
})
release_submitter_image:
env:
working-directory: ./ray-operator
name: Release Submitter Docker Images
runs-on: ubuntu-latest
steps:

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: v1.22

- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.commit }}

- name: Get revision SHA
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"

- name: Get dependencies
run: go mod download
working-directory: ${{env.working-directory}}

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install Ray
run: pip install ray[default]==2.39.0

- name: Test
run: make test-e2erayjobsubmitter
working-directory: ${{env.working-directory}}

- name: Set up Docker
uses: docker-practice/actions-setup-docker@master

- name: Build Docker Image - Submitter
run: |
IMG=kuberay/submitter:${{ steps.vars.outputs.sha_short }} make docker-submitter-image
working-directory: ${{env.working-directory}}

- name: Log in to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}

# Build submitter inside the gh runner vm directly and then copy the go binaries to docker images using the Dockerfile.submitter.buildx
- name: Build linux/amd64 submitter go binary
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: amd64
run: |
CGO_ENABLED=$CGO_ENABLED GOOS=$GOOS GOARCH=$GOARCH go build -tags strictfipsruntime -a -o submitter-$GOARCH ./rayjobsubmitter/cmd/main.go
working-directory: ${{env.working-directory}}

- name: Build linux/arm64 submitter binary
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: arm64
run: |
CGO_ENABLED=$CGO_ENABLED GOOS=$GOOS GOARCH=$GOARCH go build -tags strictfipsruntime -a -o submitter-$GOARCH ./rayjobsubmitter/cmd/main.go
working-directory: ${{env.working-directory}}

- name: Build MultiArch Image
uses: docker/build-push-action@v5
env:
PUSH: true
REPO_ORG: kuberay
REPO_NAME: submitter
with:
platforms: linux/amd64,linux/arm64
context: ${{env.working-directory}}
file: ${{env.working-directory}}/Dockerfile.submitter.buildx
push: ${{env.PUSH}}
provenance: false
tags: |
quay.io/${{env.REPO_ORG}}/${{env.REPO_NAME}}:${{ steps.vars.outputs.sha_short }}
quay.io/${{env.REPO_ORG}}/${{env.REPO_NAME}}:${{ github.event.inputs.tag }}
- name: Create tag
uses: actions/github-script@v6
with:
script: |
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/ray-operator/${{ github.event.inputs.tag }}',
sha: '${{ github.event.inputs.commit }}'
})
12 changes: 9 additions & 3 deletions ray-operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.22.4-bullseye as builder
FROM golang:1.22.4-bullseye AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -20,12 +20,18 @@ COPY rayjobsubmitter/ rayjobsubmitter/
# Build
USER root
RUN CGO_ENABLED=1 GOOS=linux go build -tags strictfipsruntime -a -o manager main.go
RUN CGO_ENABLED=1 GOOS=linux go build -tags strictfipsruntime -a -o submitter ./rayjobsubmitter/cmd/main.go
RUN CGO_ENABLED=0 GOOS=linux go build -tags strictfipsruntime -a -o submitter ./rayjobsubmitter/cmd/main.go

FROM scratch AS submitter
WORKDIR /
COPY --from=builder /workspace/submitter .
USER 65532:65532

ENTRYPOINT ["/submitter"]

FROM gcr.io/distroless/base-debian12:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
COPY --from=builder /workspace/submitter .
USER 65532:65532

ENTRYPOINT ["/manager"]
7 changes: 7 additions & 0 deletions ray-operator/Dockerfile.submitter.buildx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM scratch
ARG TARGETARCH
WORKDIR /
COPY ./submitter-${TARGETARCH} ./submitter
USER 65532:65532

ENTRYPOINT ["/submitter"]
3 changes: 3 additions & 0 deletions ray-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ build: fmt vet ## Build manager binary.
docker-image: ## Build image only
${ENGINE} build -t ${IMG} .

docker-submitter-image: ## Build image only
${ENGINE} build -t ${IMG} --target submitter .

docker-build: build docker-image ## Build image with the manager.

docker-push: ## Push image with the manager.
Expand Down

0 comments on commit d274346

Please sign in to comment.