Skip to content

Commit

Permalink
support docker to TinyMS 0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hongziqi authored and hellowaywewe committed Apr 25, 2024
1 parent 21f01c5 commit 0a4b187
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docker/tinyms/0.3.2-jupyter/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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 --upgrade -i https://pypi.mirrors.ustc.edu.cn/simple pip && \
pip install --no-cache-dir -i https://pypi.mirrors.ustc.edu.cn/simple numpy==1.17.5 tinyms==0.3.2 && \
pip install --upgrade jupyter notebook jupyterhub nbconvert -i https://pypi.mirrors.ustc.edu.cn/simple && \
fix-permissions "${CONDA_DIR}"
36 changes: 36 additions & 0 deletions docker/tinyms/0.3.2-nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ARG BASE_CONTAINER=swr.cn-south-1.myhuaweicloud.com/mindspore/mindspore-cpu:1.6.0
FROM $BASE_CONTAINER

LABEL MAINTAINER="TinyMS Authors"

# Install base tools
RUN apt-get update

# Install TinyMS cpu whl package
RUN pip install --upgrade -i https://pypi.mirrors.ustc.edu.cn/simple pip && pip install --no-cache-dir -i https://pypi.mirrors.ustc.edu.cn/simple tinyms==0.3.2
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.11 lsof libglib2.0-dev libsm6 libxrender1 libgl1-mesa-glx -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

COPY ./entrypoint.sh /usr/local/bin/
CMD ["entrypoint.sh"]
13 changes: 13 additions & 0 deletions docker/tinyms/0.3.2-nginx/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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()" &
12 changes: 12 additions & 0 deletions docker/tinyms/0.3.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG BASE_CONTAINER=swr.cn-south-1.myhuaweicloud.com/mindspore/mindspore-cpu:1.6.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 libgl1-mesa-glx -y

# Install TinyMS cpu whl package
RUN pip install --upgrade -i https://pypi.mirrors.ustc.edu.cn/simple pip && pip install --no-cache-dir -i https://pypi.mirrors.ustc.edu.cn/simple tinyms==0.3.2

0 comments on commit 0a4b187

Please sign in to comment.