Skip to content

Commit

Permalink
[CI] fix docker run options (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
guocuimi authored May 19, 2024
1 parent b60526b commit dea4e7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish_cpp_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Build ScaleLLM for cuda 12.1
run: |
docker pull vectorchai/scalellm_devel:cuda12.1
docker run --rm -it \
docker run --rm -t \
-v "$CI_CACHE_DIR":/ci_cache \
-v "$GITHUB_WORKSPACE":/ScaleLLM \
-e VCPKG_DEFAULT_BINARY_CACHE=/ci_cache/.vcpkg/bincache \
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
- name: Build ScaleLLM for cuda 11.8
run: |
docker pull vectorchai/scalellm_devel:cuda11.8
docker run --rm -it \
docker run --rm -t \
-v "$CI_CACHE_DIR":/ci_cache \
-v "$GITHUB_WORKSPACE":/ScaleLLM \
-e VCPKG_DEFAULT_BINARY_CACHE=/ci_cache/.vcpkg/bincache \
Expand Down
23 changes: 7 additions & 16 deletions tools/run_in_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ function usage() {
exit 1
}

function get_switch_user_cmd() {
local uid=$(id -u)
local gid=$(id -g)
local username=$(id -n -u)
local groupname=$(id -n -g)
local cmdline="groupadd -f ${groupname} && groupmod -o -g ${gid} ${groupname}"
cmdline+="; id -u ${username} &>/dev/null || useradd -N ${username} && usermod -o -u ${uid} -g ${gid} ${username}"
cmdline+="; chroot --userspec=${username} / "
echo "${cmdline}"
}

(( $# < 1 )) && usage

IMAGE="vectorchai/scalellm_devel:latest"
Expand All @@ -62,6 +51,9 @@ RUN_OPTS+=("-v $(pwd):$(pwd)")
RUN_OPTS+=("-v /tmp:/tmp")
RUN_OPTS+=("-v ${HOME}:${HOME}")

# run as the current user
RUN_OPTS+=("-u $(id -u):$(id -g)")

# carry over cache settings
if [[ -n "${VCPKG_DEFAULT_BINARY_CACHE}" ]]; then
RUN_OPTS+=("-v ${VCPKG_DEFAULT_BINARY_CACHE}:${VCPKG_DEFAULT_BINARY_CACHE}")
Expand All @@ -73,14 +65,13 @@ if [[ -n "${CCACHE_DIR}" ]]; then
RUN_OPTS+=("-e CCACHE_DIR=${CCACHE_DIR}")
fi

CMD="sh -c 'cd $(pwd); $@'"

CMD="$@"
[[ "${CMD}" = "" ]] && usage
[[ ! -x $(command -v docker) ]] && echo "ERROR: 'docker' command missing from PATH." && usage

[[ ! -x $(command -v docker) ]] && echo "ERROR: 'docker' command missing from PATH." && usage
if ! docker pull ${IMAGE} > /dev/null; then
echo "WARNING: Failed to docker pull image ${IMAGE}"
fi

# echo "docker run ${RUN_OPTS[@]} ${IMAGE} bash -c \"$(get_switch_user_cmd) ${CMD}\""
docker run ${RUN_OPTS[@]} ${IMAGE} bash -c "$(get_switch_user_cmd) ${CMD}"
# echo "docker run ${RUN_OPTS[@]} ${IMAGE} bash -c \"cd $(pwd); ${CMD}\""
docker run ${RUN_OPTS[@]} ${IMAGE} bash -c "cd $(pwd); ${CMD}"

0 comments on commit dea4e7a

Please sign in to comment.