From e63ee8c7c93734e04915b5cdf6ff9877d6928c8d Mon Sep 17 00:00:00 2001 From: helloway Date: Fri, 31 Dec 2021 00:56:29 +0800 Subject: [PATCH] add Dockerfile for TinyMS v0.3.0 --- docker/tinyms/0.3.0-jupyter/Dockerfile | 11 ++++++ docker/tinyms/0.3.0-nginx/Dockerfile | 46 +++++++++++++++++++++++++ docker/tinyms/0.3.0-nginx/entrypoint.sh | 13 +++++++ docker/tinyms/0.3.0/Dockerfile | 12 +++++++ 4 files changed, 82 insertions(+) create mode 100644 docker/tinyms/0.3.0-jupyter/Dockerfile create mode 100644 docker/tinyms/0.3.0-nginx/Dockerfile create mode 100755 docker/tinyms/0.3.0-nginx/entrypoint.sh create mode 100644 docker/tinyms/0.3.0/Dockerfile diff --git a/docker/tinyms/0.3.0-jupyter/Dockerfile b/docker/tinyms/0.3.0-jupyter/Dockerfile new file mode 100644 index 00000000..55a910a8 --- /dev/null +++ b/docker/tinyms/0.3.0-jupyter/Dockerfile @@ -0,0 +1,11 @@ +ARG BASE_CONTAINER=jupyter/scipy-notebook:ubuntu-18.04 +FROM $BASE_CONTAINER + +LABEL MAINTAINER="TinyMS Authors" + +# Set the default jupyter token with "tinyms" +RUN sh -c '/bin/echo -e "tinyms\ntinyms\n" | jupyter notebook password' + +# Install TinyMS cpu whl package +RUN pip install --no-cache-dir numpy==1.17.5 tinyms==0.3.0 && \ + fix-permissions "${CONDA_DIR}" diff --git a/docker/tinyms/0.3.0-nginx/Dockerfile b/docker/tinyms/0.3.0-nginx/Dockerfile new file mode 100644 index 00000000..f63f1457 --- /dev/null +++ b/docker/tinyms/0.3.0-nginx/Dockerfile @@ -0,0 +1,46 @@ +ARG BASE_CONTAINER=swr.cn-south-1.myhuaweicloud.com/mindspore/mindspore-cpu:1.5.0 +FROM $BASE_CONTAINER + +LABEL MAINTAINER="TinyMS Authors" + +# Install base tools +RUN apt-get update + +# Install TinyMS cpu whl package +RUN pip install --no-cache-dir tinyms==0.3.0 +RUN git clone https://github.com/tinyms-ai/tinyms.git + +# Ready for tinyms web frontend startup +# Install Nginx and opencv dependencies software +RUN apt-get install nginx=1.14.0-0ubuntu1.9 lsof libglib2.0-dev libsm6 libxrender1 -y + +# Configure Nginx +RUN sed -i '/include \/etc\/nginx\/sites-enabled\/\*;/a\ + client_max_body_size 200M;\ + client_body_buffer_size 200M;\ + server {\ + listen 80;\ + server_name 127.0.0.1;\ + root /tinyms/tinyms/serving/web;\ + index index.html;\ + location /predict {\ + add_header Access-Control-Allow-Origin *;\ + add_header Access-Control-Allow-Methods "GET,POST,OPTIONS";\ + add_header Access-Control-Allow-Headers "DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization";\ + proxy_pass http://localhost:5000/predict;\ + }\ + }' /etc/nginx/nginx.conf &&\ + /etc/init.d/nginx start + +# Ready for tinyms web backend startup +RUN mkdir -p /etc/tinyms/serving && cp /tinyms/tinyms/serving/config/servable.json /etc/tinyms/serving &&\ + mkdir /etc/tinyms/serving/lenet5_mnist && cd /etc/tinyms/serving/lenet5_mnist &&\ + wget https://tinyms.obs.cn-north-4.myhuaweicloud.com/ckpt_file/lenet5_mnist/lenet5.ckpt &&\ + mkdir /etc/tinyms/serving/cyclegan_cityscape && cd /etc/tinyms/serving/cyclegan_cityscape &&\ + wget https://tinyms.obs.cn-north-4.myhuaweicloud.com/ckpt_file/cyclegan_cityscape/G_A.ckpt &&\ + wget https://tinyms.obs.cn-north-4.myhuaweicloud.com/ckpt_file/cyclegan_cityscape/G_B.ckpt &&\ + mkdir /etc/tinyms/serving/ssd300_shanshui && cd /etc/tinyms/serving/ssd300_shanshui &&\ + wget https://tinyms.obs.cn-north-4.myhuaweicloud.com/ckpt_file/ssd300_shanshui/ssd300.ckpt + +COPY ./entrypoint.sh /usr/local/bin/ +CMD ["entrypoint.sh"] \ No newline at end of file diff --git a/docker/tinyms/0.3.0-nginx/entrypoint.sh b/docker/tinyms/0.3.0-nginx/entrypoint.sh new file mode 100755 index 00000000..e4027f0d --- /dev/null +++ b/docker/tinyms/0.3.0-nginx/entrypoint.sh @@ -0,0 +1,13 @@ +set -e + +host_addr=$1 + +if [[ -z $host_addr ]]; +then + echo "nothing to be instead". +else + sed -i 's/127.0.0.1/'$host_addr'/' /etc/nginx/nginx.conf +fi +/etc/init.d/nginx reload && /etc/init.d/nginx restart + +python -c "from tinyms.serving import Server; server = Server(); server.start_server()" & diff --git a/docker/tinyms/0.3.0/Dockerfile b/docker/tinyms/0.3.0/Dockerfile new file mode 100644 index 00000000..0ba83f1b --- /dev/null +++ b/docker/tinyms/0.3.0/Dockerfile @@ -0,0 +1,12 @@ +ARG BASE_CONTAINER=swr.cn-south-1.myhuaweicloud.com/mindspore/mindspore-cpu:1.5.0 +FROM $BASE_CONTAINER + +LABEL MAINTAINER="TinyMS Authors" + +# Install base tools +RUN apt-get update +# Install opencv dependencies software +RUN apt-get install libglib2.0-dev libsm6 libxrender1 -y + +# Install TinyMS cpu whl package +RUN pip install --no-cache-dir tinyms==0.3.0