Skip to content

Commit

Permalink
Fix docker build for users inside (open-mmlab#227)
Browse files Browse the repository at this point in the history
* fix the related questions of Connection failed [IP: 91.189.88.152 80] or [IP: 91.189.88.142 80] in Dockerfile

* add an ARG to control whether to change the download source for GPU and CPU Dockerfile, and update corresponding changes to the documents

* add an ARG to control whether to change the download source for GPU and CPU Dockerfile, and update corresponding changes to the documents

* update documentation

* update documentation

* fix lint error

Co-authored-by: zhangwenjun <[email protected]>
  • Loading branch information
raykindle and zhangwenjun authored Mar 17, 2022
1 parent ea54f3b commit 51e003b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docker/CPU/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ ARG ONNXRUNTIME_VERSION=1.8.1
ARG MMCV_VERSION=1.4.0
ARG CMAKE_VERSION=3.20.0
USER root

### change the system source for installing libs
ARG USE_SRC_INSIDE=false
RUN if [ ${USE_SRC_INSIDE} == true ] ; \
then \
sed -i s/archive.ubuntu.com/mirrors.aliyun.com/g /etc/apt/sources.list ; \
sed -i s/security.ubuntu.com/mirrors.aliyun.com/g /etc/apt/sources.list ; \
echo "Use aliyun source for installing libs" ; \
else \
echo "Keep the download source unchanged" ; \
fi

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libopencv-dev libspdlog-dev \
Expand Down
11 changes: 11 additions & 0 deletions docker/GPU/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ ENV FORCE_CUDA="1"

ENV DEBIAN_FRONTEND=noninteractive

### change the system source for installing libs
ARG USE_SRC_INSIDE=false
RUN if [ ${USE_SRC_INSIDE} == true ] ; \
then \
sed -i s/archive.ubuntu.com/mirrors.aliyun.com/g /etc/apt/sources.list ; \
sed -i s/security.ubuntu.com/mirrors.aliyun.com/g /etc/apt/sources.list ; \
echo "Use aliyun source for installing libs" ; \
else \
echo "Keep the download source unchanged" ; \
fi

### update apt and install libs
RUN apt-get update &&\
apt-get install -y vim libsm6 libxext6 libxrender-dev libgl1-mesa-glx git wget libssl-dev libopencv-dev libspdlog-dev --no-install-recommends &&\
Expand Down
11 changes: 11 additions & 0 deletions docs/en/tutorials/how_to_use_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ cd mmdeploy
docker build docker/GPU/ -t mmdeploy:0.1.0 --build-arg VERSION=0.1.0
```

For installing libs with the aliyun source, we can append `--build-arg USE_SRC_INSIDE=${USE_SRC_INSIDE}` to build command.
```
# GPU for example
cd mmdeploy
docker build docker/GPU/ -t mmdeploy:inside --build-arg USE_SRC_INSIDE=true
# CPU for example
cd mmdeploy
docker build docker/CPU/ -t mmdeploy:inside --build-arg USE_SRC_INSIDE=true
```

### Run docker container

After building the docker image succeed, we can use `docker run` to launch the docker service. GPU docker image for example:
Expand Down
11 changes: 11 additions & 0 deletions docs/zh_cn/tutorials/how_to_use_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ cd mmdeploy
docker build docker/GPU/ -t mmdeploy:0.1.0 --build-arg VERSION=0.1.0
```

要切换成阿里源安装依赖,我们可以将 `--build-arg USE_SRC_INSIDE=${USE_SRC_INSIDE}` 附加到构建命令中。
```
# 以 GPU 为例
cd mmdeploy
docker build docker/GPU/ -t mmdeploy:inside --build-arg USE_SRC_INSIDE=true
# 以 CPU 为例
cd mmdeploy
docker build docker/CPU/ -t mmdeploy:inside --build-arg USE_SRC_INSIDE=true
```

### 运行 docker 容器

构建 docker 镜像成功后,我们可以使用 `docker run` 启动 docker 服务。 GPU 镜像为例:
Expand Down

0 comments on commit 51e003b

Please sign in to comment.