提交 b154f8b3 编写于 作者: M Martin Jansa 提交者: Liu Jiaming

Docker: runtime_start.sh: add parameter to run standalone container

* with all volumes included in the image as well as the Apollo itself
* this image can be just fetched from your docker registry and
  executed locally
* add LOCAL_VOLUMES_CONF which can be used to define some extra volumes
  (like maps managed outside Apollo or if you want to bind nohup.out
  to host).
Signed-off-by: NMartin Jansa <Martin.Jansa@gmail.com>
上级 951e947a
......@@ -59,6 +59,6 @@ docker build \
/bin/echo -e "Docker image with prebuilt files was built and tagged as ${STANDALONE_IMAGE}, you can start it with: \n\
cd docker/build/output/standalone-scripts
docker/scripts/runtime_start.sh --local --tag standalone-${TARGET_ARCH}-${IMAGE_VERSION}\n\
docker/scripts/runtime_start.sh --standalone --local --tag standalone-${TARGET_ARCH}-${IMAGE_VERSION}\n\
and switch into it with:\n\
docker/scripts/runtime_into.sh"
docker/scripts/runtime_into_standalone.sh"
......@@ -15,5 +15,6 @@ filegroup(
"docker_base.sh",
"runtime_start.sh",
"runtime_into.sh",
"runtime_into_standalone.sh",
],
)
#!/usr/bin/env bash
###############################################################################
# Copyright 2021 The Apollo Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
DOCKER_USER="${USER}"
RUNTIME_CONTAINER="apollo_runtime_standalone_${USER}"
xhost +local:root 1>/dev/null 2>&1
docker exec -u "${DOCKER_USER}" \
-it "${RUNTIME_CONTAINER}" \
/bin/bash
xhost -local:root 1>/dev/null 2>&1
......@@ -21,6 +21,7 @@ source "${CURR_DIR}/docker_base.sh"
DOCKER_REPO="apolloauto/apollo"
RUNTIME_CONTAINER="apollo_runtime_${USER}"
RUNTIME_INSIDE="in-runtime-docker"
RUNTIME_STANDALONE="false"
TARGET_ARCH="$(uname -m)"
......@@ -59,6 +60,7 @@ OPTIONS:
-f, --fast Fast mode without pulling all map volumes.
-g, --geo <us|cn|none> Pull docker image from geolocation specific registry mirror.
-l, --local Use local docker image.
-s, --standalone Run standalone container with all volumes and apollo itself included.
-t, --tag <TAG> Specify docker image with tag <TAG> to start.
--shm-size <bytes> Size of /dev/shm . Passed directly to "docker run"
EOF
......@@ -101,6 +103,10 @@ function parse_arguments() {
USE_LOCAL_IMAGE=1
;;
-s | --standalone)
RUNTIME_STANDALONE="true"
;;
--shm-size)
shm_size="$1"
shift
......@@ -163,7 +169,8 @@ function setup_devices_and_mount_local_volumes() {
source "${APOLLO_ROOT_DIR}/scripts/apollo_base.sh"
setup_device
local volumes="-v ${APOLLO_ROOT_DIR}:/apollo"
local volumes=""
$RUNTIME_STANDALONE || volumes="-v ${APOLLO_ROOT_DIR}:/apollo"
local os_release="$(lsb_release -rs)"
case "${os_release}" in
......@@ -309,6 +316,8 @@ function main() {
exit 1
fi
$RUNTIME_STANDALONE && RUNTIME_CONTAINER="apollo_runtime_standalone_$USER"
info "Check and remove existing Apollo Runtime container ..."
remove_container_if_exists "${RUNTIME_CONTAINER}"
......@@ -319,8 +328,8 @@ function main() {
local local_volumes=
setup_devices_and_mount_local_volumes local_volumes
mount_map_volumes
mount_other_volumes
$RUNTIME_STANDALONE || mount_map_volumes
$RUNTIME_STANDALONE || mount_other_volumes
info "Starting docker container \"${RUNTIME_CONTAINER}\" ..."
......@@ -347,6 +356,7 @@ function main() {
-e NVIDIA_DRIVER_CAPABILITIES=compute,video,graphics,utility \
${MAP_VOLUMES_CONF} \
${OTHER_VOLUMES_CONF} \
${LOCAL_VOLUMES_CONF} \
${local_volumes} \
--net host \
-w /apollo \
......@@ -369,7 +379,8 @@ function main() {
ok "Congratulations! You have successfully finished setting up Apollo Runtime Environment."
ok "To login into the newly created ${RUNTIME_CONTAINER} container, please run the following command:"
ok " bash docker/scripts/runtime_into.sh"
$RUNTIME_STANDALONE || ok " bash docker/scripts/runtime_into.sh"
$RUNTIME_STANDALONE && ok " bash docker/scripts/runtime_into_standalone.sh"
ok "Enjoy!"
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册