提交 37967fcb 编写于 作者: W wangjiawei04

support running docker images

上级 ed938a1a
# Dockerfile template
FROM <<base_image>>
RUN apt-get update && \
apt-get install -y make build-essential
RUN apt-get update && \
apt-get install -y wget tar xz-utils bzip2 libcurl4-openssl-dev \
curl sed grep zlib1g-dev libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev && \
apt-get clean -y
WORKDIR /usr/bin
COPY tools/dockerfile/build_scripts /build_scripts
RUN bash /build_scripts/install_gcc.sh gcc82 && rm -rf /build_scripts
RUN cp gcc gcc.bak && cp g++ g++.bak && rm gcc && rm g++
RUN ln -s /usr/local/gcc-8.2/bin/gcc /usr/local/bin/gcc
RUN ln -s /usr/local/gcc-8.2/bin/g++ /usr/local/bin/g++
RUN ln -s /usr/local/gcc-8.2/bin/gcc /usr/bin/gcc
RUN ln -s /usr/local/gcc-8.2/bin/g++ /usr/bin/g++
ENV PATH=/usr/local/gcc-8.2/bin:$PATH
# install python
WORKDIR /home
COPY tools/dockerfile/build_scripts /build_scripts
RUN bash /build_scripts/install_python.sh <<python_version>> && rm -rf /build_scripts
# Other
# install whl and bin
WORKDIR /home
COPY tools/dockerfile/build_scripts /build_scripts
RUN bash /build_scripts/install_whl.sh 0.5.0 2.0.0 <<run_env>> <<python_version>> && rm -rf /build_scripts
# install tensorrt
WORKDIR /home
COPY tools/dockerfile/build_scripts /build_scripts
RUN bash /build_scripts/install_trt.sh && rm -rf /build_scripts
# install go
RUN wget -qO- https://dl.google.com/go/go1.14.linux-amd64.tar.gz | \
tar -xz -C /usr/local && \
mkdir /root/go && \
mkdir /root/go/bin && \
mkdir /root/go/src && \
echo "GOROOT=/usr/local/go" >> /root/.bashrc && \
echo "GOPATH=/root/go" >> /root/.bashrc && \
echo "PATH=/usr/local/go/bin:/root/go/bin:$PATH" >> /root/.bashrc
RUN wget https://paddle-serving.bj.bcebos.com/others/centos_ssl.tar && \
tar xf centos_ssl.tar && rm -rf centos_ssl.tar && \
mv libcrypto.so.1.0.2k /usr/lib/libcrypto.so.1.0.2k && mv libssl.so.1.0.2k /usr/lib/libssl.so.1.0.2k && \
ln -sf /usr/lib/libcrypto.so.1.0.2k /usr/lib/libcrypto.so.10 && \
ln -sf /usr/lib/libssl.so.1.0.2k /usr/lib/libssl.so.10 && \
ln -sf /usr/lib/libcrypto.so.10 /usr/lib/libcrypto.so && \
ln -sf /usr/lib/libssl.so.10 /usr/lib/libssl.so
EXPOSE 22
......@@ -39,6 +39,7 @@ if [ "$1" == "gcc82" ]; then
../gcc-8.2.0/configure --prefix=/usr/local/gcc-8.2 --enable-threads=posix --disable-checking --disable-multilib && \
make -j8 && make install
cd .. && rm -rf temp_gcc82
rm -rf gcc-8.2.0 gcc-8.2.0.tar.xz
cp ${lib_so_6} ${lib_so_6}.bak && rm -f ${lib_so_6} &&
ln -s /usr/local/gcc-8.2/lib64/libgfortran.so.5 ${lib_so_5} && \
ln -s /usr/local/gcc-8.2/lib64/libstdc++.so.6 ${lib_so_6} && \
......
#!/bin/bash
# Copyright (c) 2020 PaddlePaddle 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.
VERSION=$1
if [[ "$VERSION" == "2.7" ]];then
wget -q https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz && tar -xvf Python-2.7.15.tgz && cd Python-2.7.15
./configure --enable-unicode=ucs4 --enable-shared CFLAGS=-fPIC --prefix=/usr/local/ && make && make install -j8 > /dev/null && make altinstall > /dev/null && ldconfig
cd .. && rm -rf Python-2.7.15*
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python2.7 get-pip.py
rm -rf get-pip.py
elif [[ "$VERSION" == "3.6" ]];then
wget -q https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz && \
tar -xzf Python-3.6.8.tgz && cd Python-3.6.8 && \
CFLAGS="-Wformat" ./configure --prefix=/usr/local/ --enable-shared > /dev/null && \
make -j8 > /dev/null && make altinstall > /dev/null && ldconfig
cd .. && rm -rf Python-3.6.8*
elif [[ "$VERSION" == "3.7" ]];then
wget -q https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz && \
tar -xzf Python-3.7.0.tgz && cd Python-3.7.0 && \
CFLAGS="-Wformat" ./configure --prefix=/usr/local/ --enable-shared > /dev/null && \
make -j8 > /dev/null && make altinstall > /dev/null && ldconfig
cd .. && rm -rf Python-3.7.0*
fi
#!/bin/bash
# Copyright (c) 2020 PaddlePaddle 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.
SERVING_VERSION=$1
PADDLE_VERSION=$2
RUN_ENV=$3 # cpu/10.1 10.2
PYTHON_VERSION=$4
client_release="paddle-serving-client==$SERVING_VERSION"
app_release="paddle-serving-app==0.3.1"
if [[ "$RUN_ENV" == "cpu" ]];then
server_release="paddle-serving-server==$SERVING_VERSION"
python$PYTHON_VERSION -m pip install $client_release $app_release $server_release
python$PYTHON_VERSION -m pip install paddlepaddle==${PADDLE_VERSION}
cd /usr/local/
wget https://paddle-serving.bj.bcebos.com/bin/serving-cpu-noavx-openblas-${SERVING_VERSION}.tar.gz
tar xf serving-cpu-noavx-openblas-${SERVING_VERSION}.tar.gz
echo "export SERVING_BIN=$PWD/serving-cpu-noavx-openblas-${SERVING_VERSION}/serving">>/root/.bashrc
rm -rf serving-cpu-noavx-openblas-${SERVING_VERSION}.tar.gz
cd -
elif [[ "$RUN_ENV" == "cuda10.1" ]];then
server_release="paddle-serving-server-gpu==$SERVING_VERSION.post101"
python$PYTHON_VERSION -m pip install $client_release $app_release $server_release
python$PYTHON_VERSION -m pip install paddlepaddle-gpu==${PADDLE_VERSION}
cd /usr/local/
wget https://paddle-serving.bj.bcebos.com/bin/serving-gpu-101-${SERVING_VERSION}.tar.gz
tar xf serving-gpu-101-${SERVING_VERSION}.tar.gz
echo "export SERVING_BIN=$PWD/serving-gpu-101-${SERVING_VERSION}/serving">>/root/.bashrc
rm -rf serving-gpu-101-${SERVING_VERSION}.tar.gz
cd -
elif [[ "$RUN_ENV" == "cuda10.2" ]];then
server_release="paddle-serving-server-gpu==$SERVING_VERSION.post102"
python$PYTHON_VERSION -m pip install $client_release $app_release $server_release
python$PYTHON_VERSION -m pip install paddlepaddle-gpu==${PADDLE_VERSION}
cd /usr/local/
wget https://paddle-serving.bj.bcebos.com/bin/serving-gpu-102-${SERVING_VERSION}.tar.gz
tar xf serving-gpu-102-${SERVING_VERSION}.tar.gz
echo "export SERVING_BIN=$PWD/serving-gpu-102-${SERVING_VERSION}/serving">>/root/.bashrc
rm -rf serving-gpu-102-${SERVING_VERSION}.tar.gz
cd -
fi
#!/bin/sh
#abort on error
set -e
function usage
{
echo "usage: arg_parse_example -a AN_ARG -s SOME_MORE_ARGS [-y YET_MORE_ARGS || -h]"
echo " ";
echo " --env : running env, cpu/cuda10.1/cuda10.2/cuda11";
echo " --python : python version, 2.7/3.6/3.7 ";
echo " --serving : serving version(0.5.0)";
echo " --paddle : paddle version(2.0.1)"
echo " --image_name : image name(default serving_runtime:env-python)"
echo " -h | --help : helper";
}
function parse_args
{
# positional args
args=()
# named args
while [ "$1" != "" ]; do
case "$1" in
--env ) env="$2"; shift;;
--python ) python="$2"; shift;;
--serving ) serving="$2"; shift;;
--paddle ) paddle="$2"; shift;;
--image_name ) image_name="$2"; shift;;
-h | --help ) usage; exit;; # quit and show usage
* ) args+=("$1") # if no match, add it to the positional args
esac
shift # move to next kv pair
done
# restore positional args
set -- "${args[@]}"
# set positionals to vars
positional_1="${args[0]}"
positional_2="${args[1]}"
# validate required args
if [[ -z "${paddle}" || -z "${env}" || -z "${python}" || -z "${serving}" ]]; then
echo "Invalid arguments"
usage
exit;
fi
if [[ -z "${image_name}" ]]; then
image_name="serving_runtime:$env-$python"
echo "image_name is not assigned, so it will be set ($image_name)."
fi
}
function run
{
parse_args "$@"
echo "named arg: env: $env"
if [ $env == "cpu" ]; then
base_image="ubuntu:16.04"
elif [ $env == "cuda10.1" ]; then
base_image="nvidia\/cuda:10.1-cudnn7-runtime-ubuntu16.04"
elif [ $env == "cuda10.2" ]; then
base_image="nvidia\/cuda:10.2-cudnn8-runtime-ubuntu16.04"
fi
echo "base image: $base_image"
echo "named arg: python: $python"
echo "named arg: serving: $serving"
echo "named arg: paddle: $paddle"
echo "named arg: image_name: $image_name"
sed -e "s/<<base_image>>/$base_image/g" -e "s/<<python_version>>/$python/g" -e "s/<<run_env>>/$env/g" Dockerfile.runtime_template > Dockerfile.tmp
docker build --build-arg ftp_proxy=http://172.19.57.45:3128 --build-arg https_proxy=http://172.19.57.45:3128 --build-arg http_proxy=http://172.19.57.45:3128 --build-arg HTTP_PROXY=http://172.19.57.45:3128 --build-arg HTTPS_PROXY=http://172.19.57.45:3128 -t $image_name -f Dockerfile.tmp .
}
run "$@";
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册