Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docker image] Nightly build of docker image #2229

Merged
merged 35 commits into from
Jan 28, 2024

Conversation

PratikKumar125
Copy link
Contributor

@PratikKumar125 PratikKumar125 commented Jul 13, 2023

Added two workflow files.

  1. release-build.yaml, to build and push docker-images whenever any changes are made to existing release/* branch or any new release/* branch is created.
  2. nightly-build.yaml, to build the master branch in every 24 Hours with the latest tag and push them to dockerhub.

NOTE:-You need to store dockerhub username and password as github secrets with the same keys as follows :-

  1. DOCKER_USERNAME
  2. DOCKER_PASSWORD

@romilbhardwaj romilbhardwaj self-requested a review July 13, 2023 15:23
Copy link
Collaborator

@romilbhardwaj romilbhardwaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, thanks @PratikKumar125! Trying it out now. Left some comments.

run: |
docker build -t $DOCKER_USERNAME/skypilot:latest .
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker push $DOCKER_USERNAME/skypilot:latest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: new line at the end?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for other file

@@ -0,0 +1,24 @@
name: Nightly Build
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this docker-nightly-build so we don't confuse this with pypi/other builds?

@@ -0,0 +1,40 @@
name: Release Build
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this docker-release-build?

on:
push:
branches:
- 'releases/*'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use 'releases/**' to also catch any nested branches

@@ -0,0 +1,24 @@
name: Nightly Build

on:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add workflow_dispatch to allow manual override when required?

build:
runs-on: ubuntu-latest

steps:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a check to run the nightly build only if there have been changes in the last 24 hours? You may want to refer to this.

env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before building the nightly, can we also update the version str like we're planning to do in #1446? See reference code here:

- name: Set release version
run: |
RELEASE_VERSION=$(date +%Y%m%d)
sed -i "s/{{SKYPILOT_COMMIT_SHA}}/${{ github.sha }}/g" sky/__init__.py
sed -i "s/__version__ = '.*'/__version__ = '1.0.0-dev${RELEASE_VERSION}'/g" sky/__init__.py
sed -i "s/name='skypilot',/name='skypilot-nightly',/g" sky/setup_files/setup.py

@Michaelvll
Copy link
Collaborator

Michaelvll commented Jul 14, 2023

For discussion: How about having the docker release workflow in the same workflow file as the pypi release so as to make sure the commit hash are the same for both nightly release? https://github.com/skypilot-org/skypilot/blob/master/.github/workflows/pypi-nightly-build.yml

@romilbhardwaj
Copy link
Collaborator

For discussion: How about having the docker release workflow in the same workflow file as the pypi release so as to make sure the commit hash are the same for both nightly release? https://github.com/skypilot-org/skypilot/blob/master/.github/workflows/pypi-nightly-build.yml

+1 for having the same version. However, it might be better to have them as two different workflows for isolation (in case something breaks in either of the flows).. How about we pick the head commit at 12AM PT for both workflows to ensure version is same?

@romilbhardwaj
Copy link
Collaborator

Another thing to think about and probably can be deferred to a future PR - can we have different images for different dependencies? E.g., skypilot-aws:latest, skypilot-gcp:latest and so on? skypilot:latest can still have all dependencies installed.

This would help reduce bloat and pull times for users who use only a single cloud.

@PratikKumar125
Copy link
Contributor Author

Made some suggested changes. Require review.

@Michaelvll Michaelvll mentioned this pull request Jul 15, 2023
2 tasks
@Michaelvll Michaelvll changed the title CI-CD-#2193 [Docker image] Nightly build of docker image Oct 3, 2023
@Michaelvll
Copy link
Collaborator

Changed this to use the latest nightly build on pypi as a single source of truth. Tested in a fork and it works: https://github.com/michaelvll/skypilot/actions/workflows/docker-nightly-build.yaml

Copy link
Collaborator

@romilbhardwaj romilbhardwaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Michaelvll!

apt install rsync vim -y && \
rm -rf /var/lib/apt/lists/*

RUN pip install "skypilot-nightly[aws,gcp,azure,kubernetes]==$LATEST_VERSION" --no-cache-dir
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth a quick check to measure the size difference between an image with skypilot-nightly[aws,gcp,azure,kubernetes] vs skypilot-nightly[all]. If not too big, perhaps we can ship with skypilot-nightly[all]?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! I was using the older python version and the installation of [all] seems taking forever, due to some dependency issue with the kubernetes extra for python 3.9. I just switched the base image to use python 3.10, and it seems working nicely with [all]

push: true
tags: "${{ secrets.DOCKER_USERNAME }}/skypilot-nightly:latest,${{ secrets.DOCKER_USERNAME }}/skypilot-nightly:$LATEST_VERSION"
cache-from: type=gha
cache-to: type=gha,mode=max
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: since running a linux/amd64 image on apple silicon can be a bit slow because of emulation (e.g., on my M2 Mac, sky -v takes 4 seconds on this image compared to 1 second running natively), consider adding builds for apple silicon.

IIUC from this guide, it should involve:

  1. Adding the qemu action above
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
  1. In docker/build-push-action@v5, add:
platforms: linux/amd64,linux/arm64

Feel free to defer for a future PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! I just tried adding it, but it seems the conda install -c conda-forge google-cloud-sdk fail to be installed in the linux/arm64 version. Do you have an idea how to resolve it?

@Michaelvll Michaelvll merged commit 9c08b7b into skypilot-org:master Jan 28, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants