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

Docker: standalone.x86_64.sh: add script for creating standalone docker image

* with all the volumes and apollo itself included
Signed-off-by: NMartin Jansa <Martin.Jansa@gmail.com>
上级 22ab0d67
ARG DOCKER_REPO=apolloauto/apollo
ARG TARGET_ARCH=x86_64
ARG IMAGE_VERSION=18.04-20210315_2158
ARG BASE_IMAGE=${DOCKER_REPO}:runtime-${TARGET_ARCH}-${IMAGE_VERSION}
ARG DOCKER_USER
ARG DOCKER_USER_ID
ARG DOCKER_GRP
ARG DOCKER_GRP_ID
FROM ${DOCKER_REPO}:data_volume-audio_model-${TARGET_ARCH}-latest as apollo_audio_volume
FROM ${DOCKER_REPO}:yolov4_volume-emergency_detection_model-${TARGET_ARCH}-latest as apollo_yolov4_volume
FROM ${DOCKER_REPO}:faster_rcnn_volume-traffic_light_detection_model-${TARGET_ARCH}-latest as apollo_faster_rcnn_volume
FROM ${DOCKER_REPO}:smoke_volume-yolo_obstacle_detection_model-${TARGET_ARCH}-latest as apollo_smoke_volume
FROM ${BASE_IMAGE}
ENV DOCKER_USER=${DOCKER_USER:-apollo}
ENV DOCKER_USER_ID=${DOCKER_USER_ID:-1001}
ENV DOCKER_GRP=${DOCKER_GRP:-apollo}
ENV DOCKER_GRP_ID=${DOCKER_GRP_ID:-1001}
# We need to copy output first to make sure that the top-level /apollo directory is also owned by ${DOCKER_USER_ID}:${DOCKER_GRP_ID},
# because COPY --chown creates target directory as root and only chowns the files it copies.
# If we copy some volume first then /apollo is owned by root and different user will fail to create e.g.
# nohup.out or /apollo/data there (in runtime image it's overlayed by a volume from host, so it doesn't harm)
COPY \
--chown=${DOCKER_USER_ID}:${DOCKER_GRP_ID} \
output \
/apollo
COPY \
--from=apollo_audio_volume \
--chown=${DOCKER_USER_ID}:${DOCKER_GRP_ID} \
/apollo/modules/audio \
/apollo/modules/audio
COPY \
--from=apollo_yolov4_volume \
--chown=${DOCKER_USER_ID}:${DOCKER_GRP_ID} \
/apollo/modules/perception/camera/lib/obstacle/detector/yolov4 \
/apollo/modules/perception/camera/lib/obstacle/detector/yolov4
COPY \
--from=apollo_faster_rcnn_volume \
--chown=${DOCKER_USER_ID}:${DOCKER_GRP_ID} \
/apollo/modules/perception/production/data/perception/camera/models/traffic_light_detection \
/apollo/modules/perception/production/data/perception/camera/models/traffic_light_detection
COPY \
--from=apollo_smoke_volume \
--chown=${DOCKER_USER_ID}:${DOCKER_GRP_ID} \
/apollo/modules/perception/production/data/perception/camera/models/yolo_obstacle_detector \
/apollo/modules/perception/production/data/perception/camera/models/yolo_obstacle_detector
RUN /apollo/scripts/docker_start_user.sh
#!/bin/bash
# Copyright (c) 2021 LG Electronics, Inc. All Rights Reserved
DOCKER_REPO=apolloauto/apollo
TARGET_ARCH=x86_64
IMAGE_VERSION=18.04-20210315_2158
DEV_IMAGE=${DOCKER_REPO}:dev-${TARGET_ARCH}-${IMAGE_VERSION}
RUNTIME_IMAGE=${DOCKER_REPO}:runtime-${TARGET_ARCH}-${IMAGE_VERSION}
STANDALONE_IMAGE=${DOCKER_REPO}:standalone-${TARGET_ARCH}-${IMAGE_VERSION}
set -e
if [ "$1" == "rebuild" ] ; then
docker/scripts/dev_start.sh -y
docker exec -u $USER -t apollo_dev_$USER bazel clean --expunge || true
docker exec -u $USER -t apollo_dev_$USER /apollo/apollo.sh release --clean --resolve
fi
if [ "$1" == "reinstall" ] ; then
docker exec -u $USER -t apollo_dev_$USER /apollo/apollo.sh release --clean --resolve
fi
rm -rf docker/build/output
# Expects that the Apollo was already built in apollo_dev_$USER
if ! [ -f output/syspkgs.txt ] ; then
echo "ERROR: this directory doesn't have output/syspkgs.txt"
echo " make sure apollo was built with \"/apollo/apollo.sh release --resolve\""
echo " or add \"rebuild\" parameter to this script"
echo " and it will be built automatically"
exit 1
fi
cp output/syspkgs.txt docker/build/
docker build \
--build-arg DEV_IMAGE_IN=${DEV_IMAGE} \
--build-arg GEOLOC=us \
--build-arg CUDA_LITE=11.1 \
--build-arg CUDNN_VERSION=8.0.4.30 \
--build-arg TENSORRT_VERSION=7.2.1 \
-f docker/build/runtime.x86_64.dockerfile.sample \
docker/build/ \
-t ${RUNTIME_IMAGE}
rm -f docker/build/syspkgs.txt
mv output docker/build
mkdir -p docker/build/output/standalone-scripts/docker/scripts
cp docker/scripts/{runtime_start.sh,runtime_into_standalone.sh,docker_base.sh} docker/build/output/standalone-scripts/docker/scripts
mkdir -p docker/build/output/standalone-scripts/scripts
cp scripts/{common.bashrc,apollo_base.sh,apollo.bashrc} docker/build/output/standalone-scripts/scripts
docker build \
--build-arg BASE_IMAGE=${RUNTIME_IMAGE} \
-f docker/build/standalone.x86_64.dockerfile \
docker/build/ \
-t ${STANDALONE_IMAGE}
/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\
and switch into it with:\n\
docker/scripts/runtime_into.sh"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册