Skip to content

Commit

Permalink
update docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
allwefantasy committed Apr 19, 2020
1 parent 807b1ac commit b5f1d8e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 108 deletions.
55 changes: 21 additions & 34 deletions dev/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,52 +1,39 @@
FROM debian:stretch

# $ docker build . -t continuumio/miniconda3:latest -t continuumio/miniconda3:4.5.11
# $ docker run --rm -it continuumio/miniconda3:latest /bin/bash
# $ docker push continuumio/miniconda3:latest
# $ docker push continuumio/miniconda3:4.5.11
FROM ubuntu:18.04

RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

RUN apt-get update && apt-get install -y --no-install-recommends apt-utils build-essential software-properties-common curl wget unzip nano git
RUN add-apt-repository -y ppa:openjdk-r/ppa
RUN apt-get update
RUN apt-get -y install openjdk-8-jdk

ENV PATH /opt/conda/bin:$PATH

RUN apt-get update --fix-missing && \
apt-get install -y openjdk-8-jre-headless wget bzip2 ca-certificates curl git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# RUN apt-get update --fix-missing && \
# apt-get install -y openjdk-8-jre-headless wget bzip2 ca-certificates curl git && \
# apt-get clean && \
# rm -rf /var/lib/apt/lists/*

RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.5.11-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda clean -tipsy && \
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate base" >> ~/.bashrc

# ENV TINI_VERSION v0.16.1
# ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini
# RUN chmod +x /usr/bin/tini
echo ". /opt/conda/etc/profile.d/conda.sh" >> /etc/profile && \
echo "conda activate base" >> /etc/profile && \
. /etc/profile

#RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
#RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
#RUN conda config --set show_channel_urls yes

RUN mkdir ~/.pip

RUN echo "[global]\n trusted-host = mirrors.aliyun.com\n index-url = https://mirrors.aliyun.com/pypi/simple" > ~/.pip/pip.conf

ARG MAVEN_VERSION=3.6.0
ARG USER_HOME_DIR="/root"
ARG SHA=fae9c12b570c3ba18116a4e26ea524b29f7279c17cbaadc3326ca72927368924d9131d11b9e851b8dc9162228b6fdea955446be41207a5cfc61283dd8a561d2f
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries

RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
RUN conda create --name dev python=3.6 --yes --quiet
RUN . /etc/profile && conda activate dev && pip install --no-cache-dir \
Cython numpy pandas scikit-learn plotly pyarrow==0.10.0 ray==0.8.0 \
aiohttp psutil setproctitle grpcio \
watchdog requests click uuid sfcli pyjava


ARG SPARK_VERSION
Expand Down
117 changes: 43 additions & 74 deletions docs/gitbook/zh/installation/docker.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
## 使用Docker安装体验

> 因为自己的电脑支撑不起docker的空间开销,docker版本不在更新。优先推荐大家使用[下载预编译的安装包](https://docs.mlsql.tech/zh/installation/downloa_prebuild_package.html)
【文档更新日志:2020-04-19】

在终端执行如下指令:
> Note: 本文档适用于MLSQL Engine 1.6.0-SNAPSHOT/1.6.0 及以上版本。
> 对应的Spark版本可支持2.4.5
>
```shell
bash <(curl http://download.mlsql.tech/scripts/run-all.sh)
```

如果上述运行方式有问题的话,您还可以尝试如下方式:

```
wget http://download.mlsql.tech/scripts/run-all.sh
chmod u+x run-all.sh
./run-all.sh
```

注意事项:

0. Linux/MacOS,需要有Docker环境
1. 系统会检测 9002,9003,8080,3306四个端口是否被占用
2. 如果看到MySQL连接错误。这是脚本在检测MySQL启动后何时可用。不是错误,请放心。

## 注意

因为我们将镜像发布在了Docker Hub,不同网络情况下不是很稳定。
如果docker镜像拉去缓慢,可以设置阿里云镜像。首先去阿里云开通镜像服务,然后进入
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors 页面,里面会教你做镜像加速。

Expand All @@ -43,77 +30,59 @@ systemctl daemon-reload
systemctl restart docker
```

执行时间取决于你的下载速度。安装完毕后,你可以通过docker ps 常看运行的Docker容器。

![image.png](http://docs.mlsql.tech/upload_images/1063603-004da41021835b54.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


## 快速配置向导

在能够进入控制台使用前,你需要进行一些配置,请按照如下方式进行配置。


访问 http://127.0.0.1:9002 进行注册。只支持Gmail邮箱。

![image.png](http://docs.mlsql.tech/upload_images/1063603-5dbdcd1e735e9681.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

进入后看到如下界面,点击Team:

![image.png](http://docs.mlsql.tech/upload_images/WX20190807-095256.png)
执行时间取决于你的下载速度。

可以见到一个快速设置页:
## 最快方式

![image.png](http://docs.mlsql.tech/upload_images/WX20190807-095357.png)

随便填入一个team名称,点击下一步:


![image.png](http://docs.mlsql.tech/upload_images/WX20190807-095440.png)
```
bash <(curl http://download.mlsql.tech/scripts/run-all.sh)
```

选中刚才建立的team,然后设置一个角色,下一步
## 手动搭建

![image.png](http://docs.mlsql.tech/upload_images/WX20190807-095542.png)
创建网络:

把自己邀请到team1/admin里,下一步:
```
docker network rm mlsql-network
docker network create mlsql-network
```

![image.png](http://docs.mlsql.tech/upload_images/WX20190807-095644.png)
启动MySQL容器:

开始给team和role添加后端engine,这里url 一定要 填写: mlsql-server:9003. 因为我使用了docker网络。点击下一步:
```
docker run --name mlsql-db -p 3306:3306 \
--network mlsql-network \
-e MYSQL_ROOT_PASSWORD=mlsql \
-d techmlsql/mlsql-db:1.6.0-SNAPSHOT
```

![image.png](http://docs.mlsql.tech/upload_images/WX20190807-095834.png)
启动MLSQL Engine:

将刚才的添加的engine设置为默认的engine,点击下一步:
```
docker run --name mlsql-server -d \
--network mlsql-network \
-p 9003:9003 \
techmlsql/mlsql:spark_2.4-1.6.0-SNAPSHOT
```

![image.png](http://docs.mlsql.tech/upload_images/WX20190807-095955.png)
启动 MLSQL Console:

完成。
```
docker run --name mlsql-console \
--network mlsql-network \
-p 9002:9002 \
-e MLSQL_ENGINE_URL=http://mlsql-server:9003 \
-e MY_URL=http://mlsql-console:9002 \
-e USER_HOME=/tmp/users \
-e MYSQL_HOST=mlsql-db \
-d \
techmlsql/mlsql-console:1.6.0-SNAPSHOT
```

![image.png](http://docs.mlsql.tech/upload_images/WX20190807-100026.png)

这个时候返回主界面,然后执行一个命令看是否都联通了(第一次运行会比较久):

![image.png](http://docs.mlsql.tech/upload_images/WX20190807-100144.png)

大工告成。如果你想要看更多示例,请登录 try.mlsql.tech,然后用一下用户名登录查看:

```
account: [email protected]
password: 123456
```


## 结束语
在docker里我们默认关闭了表权限校验,否则使用时,使用jdbc等各种数据的时候,都需要添加权限,比较繁琐。
用户也可以修改run-all.sh脚本。
在启动MLSQL Console的时候,加上-e ENABLE_AUTH_CENTER=true 即可。

```shell
#!/usr/bin/env bash

java -cp .:${MLSQL_CONSOLE_JAR} tech.mlsql.MLSQLConsole \
-mlsql_cluster_url ${MLSQL_CLUSTER_URL} \
-my_url ${MY_URL} \
-user_home ${USER_HOME} \
-enable_auth_center ${ENABLE_AUTH_CENTER:-false} \
-config ${MLSQL_CONSOLE_CONFIG_FILE}
```

0 comments on commit b5f1d8e

Please sign in to comment.