Skip to content

Commit

Permalink
fix(CLI): 🔨 use latest version for local build (#763)
Browse files Browse the repository at this point in the history
* fix(CLI) 🐛 use dev version for local build

Signed-off-by: Wei Zhang <kweizh@gmail.com>

* feat(ci): ✨ built latest docker image tag when release

Signed-off-by: Wei Zhang <kweizh@gmail.com>

* fix(built): 🔥 drop debug code

Signed-off-by: Wei Zhang <kweizh@gmail.com>

Signed-off-by: Wei Zhang <kweizh@gmail.com>
  • Loading branch information
zwpaper committed Aug 12, 2022
1 parent 4f24b0e commit 590b4c0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
run: |
docker login --username "${DOCKERIO_USERNAME}" --password "${DOCKERIO_PASSWORD}"
./base-images/build.sh
DOCKER_IMAGE_TAG=latest ./base-images/build.sh
cache_publish:
name: Build & Push the remote cache
# only trigger on main repo when tag starts with v
Expand Down
10 changes: 5 additions & 5 deletions base-images/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ ROOT_DIR=`dirname $0`

GIT_TAG_VERSION=$(git describe --tags --abbrev=0 | sed -r 's/[v]+//g') # remove v from version
ENVD_VERSION="${ENVD_VERSION:-$GIT_TAG_VERSION}"
DOCKER_IMAGE_TAG="${DOCKER_IMAGE_TAG:-$ENVD_VERSION}"
DOCKER_HUB_ORG="${DOCKER_HUB_ORG:-tensorchord}"
PYTHON_VERSION="${PYTHON_VERSION:-3.9}"
ENVD_OS="${ENVD_OS:-ubuntu20.04}"
JULIA_VERSION="${JULIA_VERSION:-1.8rc1}"
RLANG_VERSION="${RLANG_VERSION:-4.2}"


cd ${ROOT_DIR}
# ubuntu 22.04 build require moby/buildkit version greater than 0.8.1
if ! docker buildx inspect cuda; then
Expand All @@ -26,26 +26,26 @@ docker buildx build \
--build-arg ENVD_VERSION=${ENVD_VERSION} \
--build-arg ENVD_SSH_IMAGE=ghcr.io/tensorchord/envd-ssh-from-scratch \
--pull --push --platform linux/x86_64,linux/arm64 \
-t ${DOCKER_HUB_ORG}/python:${PYTHON_VERSION}-${ENVD_OS}-envd-v${ENVD_VERSION} \
-t ${DOCKER_HUB_ORG}/python:${PYTHON_VERSION}-${ENVD_OS}-envd-v${DOCKER_IMAGE_TAG} \
-f python${PYTHON_VERSION}-${ENVD_OS}.Dockerfile .
docker buildx build --build-arg IMAGE_NAME=docker.io/nvidia/cuda \
--build-arg ENVD_VERSION=${ENVD_VERSION} \
--build-arg ENVD_SSH_IMAGE=ghcr.io/tensorchord/envd-ssh-from-scratch \
--pull --push --platform linux/x86_64,linux/arm64 \
-t ${DOCKER_HUB_ORG}/python:${PYTHON_VERSION}-${ENVD_OS}-cuda11.6-cudnn8-envd-v${ENVD_VERSION} \
-t ${DOCKER_HUB_ORG}/python:${PYTHON_VERSION}-${ENVD_OS}-cuda11.6-cudnn8-envd-v${DOCKER_IMAGE_TAG} \
-f python${PYTHON_VERSION}-${ENVD_OS}-cuda11.6.Dockerfile .

# TODO(gaocegege): Support linux/arm64
docker buildx build \
--build-arg ENVD_VERSION=${ENVD_VERSION} \
--build-arg ENVD_SSH_IMAGE=ghcr.io/tensorchord/envd-ssh-from-scratch \
-t ${DOCKER_HUB_ORG}/r-base:${RLANG_VERSION}-envd-v${ENVD_VERSION} \
-t ${DOCKER_HUB_ORG}/r-base:${RLANG_VERSION}-envd-v${DOCKER_IMAGE_TAG} \
--pull --push --platform linux/x86_64 \
-f r${RLANG_VERSION}.Dockerfile .
docker buildx build \
--build-arg ENVD_VERSION=${ENVD_VERSION} \
--build-arg ENVD_SSH_IMAGE=ghcr.io/tensorchord/envd-ssh-from-scratch \
-t ${DOCKER_HUB_ORG}/julia:${JULIA_VERSION}-${ENVD_OS}-envd-v${ENVD_VERSION} \
-t ${DOCKER_HUB_ORG}/julia:${JULIA_VERSION}-${ENVD_OS}-envd-v${DOCKER_IMAGE_TAG} \
--pull --push --platform linux/x86_64,linux/arm64 \
-f julia${JULIA_VERSION}-${ENVD_OS}.Dockerfile .
cd - > /dev/null
28 changes: 13 additions & 15 deletions pkg/lang/ir/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,10 @@ func (g Graph) compileCopy(root llb.State) llb.State {
return result
}

func (g *Graph) compileCUDAPackages() llb.State {
root := llb.Image(fmt.Sprintf(
func (g *Graph) compileCUDAPackages(org, version string) llb.State {
return llb.Image(fmt.Sprintf(
"docker.io/%s/python:3.9-%s-cuda%s-cudnn%s-envd-%s",
viper.GetString(flag.FlagDockerOrganization),
g.OS, *g.CUDA, *g.CUDNN, version.GetGitTagFromVersion()))
return root
org, g.OS, *g.CUDA, *g.CUDNN, version))
}

func (g Graph) compileSystemPackages(root llb.State) llb.State {
Expand Down Expand Up @@ -122,16 +120,20 @@ func (g *Graph) compileBase() (llb.State, error) {
logger.Debug("compile base image")

var base llb.State
org := viper.GetString(flag.FlagDockerOrganization)
v := version.GetGitTagFromVersion()
if v == "" {
// empty version tag only appear in dev built, set to `latest` if so.
v = "latest"
}
// Do not update user permission in the base image.
if g.Image != nil {
logger.WithField("image", *g.Image).Debugf("using custom base image")
return llb.Image(*g.Image), nil
} else if g.CUDA == nil && g.CUDNN == nil {
switch g.Language.Name {
case "r":
base = llb.Image(fmt.Sprintf("docker.io/%s/r-base:4.2-envd-%s",
viper.GetString(flag.FlagDockerOrganization),
version.GetGitTagFromVersion()))
base = llb.Image(fmt.Sprintf("docker.io/%s/r-base:4.2-envd-%s", org, v))
// r-base image already has GID 1000.
// It is a trick, we actually use GID 1000
if g.gid == 1000 {
Expand All @@ -142,17 +144,13 @@ func (g *Graph) compileBase() (llb.State, error) {
}
case "python":
base = llb.Image(fmt.Sprintf(
"docker.io/%s/python:3.9-ubuntu20.04-envd-%s",
viper.GetString(flag.FlagDockerOrganization),
version.GetGitTagFromVersion()))
"docker.io/%s/python:3.9-ubuntu20.04-envd-%s", org, v))
case "julia":
base = llb.Image(fmt.Sprintf(
"docker.io/%s/julia:1.8rc1-ubuntu20.04-envd-%s",
viper.GetString(flag.FlagDockerOrganization),
version.GetGitTagFromVersion()))
"docker.io/%s/julia:1.8rc1-ubuntu20.04-envd-%s", org, v))
}
} else {
base = g.compileCUDAPackages()
base = g.compileCUDAPackages(org, v)
}
var res llb.ExecState

Expand Down

0 comments on commit 590b4c0

Please sign in to comment.