Zhang Li 2 years ago
parent
commit
a17797e244
5 changed files with 199 additions and 0 deletions
  1. 118 0
      Dockerfile
  2. 15 0
      Makefile
  3. 16 0
      README.md
  4. 16 0
      docker-compose.yml
  5. 34 0
      environment.yml

+ 118 - 0
Dockerfile

@@ -0,0 +1,118 @@
+FROM ubuntu:18.04 AS builder
+
+RUN 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
+
+ENV LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:zh LC_ALL=zh_CN.UTF-8 DEBIAN_FRONTEND=noninteractive
+
+RUN rm -rf  /etc/apt/sources.list.d/  && apt update
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+    supervisor \
+    iputils-ping \
+    wget \
+    zsh \
+    build-essential \
+    cmake \
+    git \
+    curl \
+    vim \
+    ca-certificates \
+    libjpeg-dev \
+    zip \
+    unzip \
+    libpng-dev \
+    openssh-server \
+    autojump \
+    language-pack-zh-hans \
+    ttf-wqy-zenhei \
+    libgl1-mesa-glx  \
+    libglib2.0-0 \
+    locales &&\
+    rm -rf /var/lib/apt/lists/*
+
+
+RUN locale-gen zh_CN.UTF-8
+RUN dpkg-reconfigure locales
+
+
+CMD ["supervisord", "-n"]
+
+FROM builder as builder1
+
+ENV PYTHON_VERSION 3
+RUN chsh -s `which zsh`
+RUN curl -o ~/miniconda.sh -O  https://repo.anaconda.com/miniconda/Miniconda${PYTHON_VERSION}-latest-Linux-x86_64.sh  && \
+    chmod +x ~/miniconda.sh && \
+    ~/miniconda.sh -b -p /opt/conda && \
+    rm ~/miniconda.sh
+
+RUN ln /opt/conda/bin/conda /usr/local/bin/conda
+RUN conda init zsh
+RUN conda install mamba -n base -c conda-forge
+RUN ln /opt/conda/bin/mamba /usr/local/bin/mamba && mamba init zsh
+
+
+FROM builder1 as builder2
+
+ENV WORKDIR /workspace
+WORKDIR ${WORKDIR}
+ADD environment.yml /environment.yml
+RUN mamba update -n base -c defaults conda -y && mamba env create -f /environment.yml && rm -rf /root/.cache
+
+# RUN /opt/conda/envs/py38/bin/python -m ipykernel install --name py38 --display-name "py38"
+# RUN echo "c.MultiKernelManager.default_kernel_name = 'py38'">>/root/.jupyter/jupyter_notebook_config.py
+RUN echo "\
+[program:be]\n\
+directory=%(ENV_WORKDIR)s\n\
+command=/opt/conda/envs/py38/bin/gunicorn server:app --workers 1 --worker-class=uvicorn.workers.UvicornWorker  --bind 0.0.0.0:8080 --reload \n\
+autorestart=true\n\
+startretries=0\n\
+redirect_stderr=true\n\
+stdout_logfile=/var/log/be.log\n\
+stdout_logfile_maxbytes=50MB\n\
+environment=PYTHONUNBUFFERED=1\n\
+" > /etc/supervisor/conf.d/be.conf
+
+ADD . ${WORKDIR}
+EXPOSE 8080
+
+
+
+FROM builder2 as builder3
+
+RUN apt-get update && apt-get install -y --no-install-recommends openssh-server && rm -rf /var/lib/apt/lists/*
+RUN mkdir /var/run/sshd
+RUN echo 'root:root' | chpasswd
+RUN sed -i 's/.*PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config
+# SSH login fix. Otherwise user is kicked off after login
+RUN sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
+
+RUN echo "\
+[program:sshd] \n\
+command=/usr/sbin/sshd -D\n\
+autorestart=True\n\
+autostart=True\n\
+redirect_stderr = true\n\
+" > /etc/supervisor/conf.d/sshd.conf
+
+EXPOSE 22
+
+
+# RUN mamba install -y jupyterlab -n base && mamba init zsh
+# RUN /opt/conda/bin/jupyter notebook --generate-config && \
+#     echo "c.NotebookApp.password='argon2:\$argon2id\$v=19\$m=10240,t=10,p=8\$+zIUCF9Uk2FiCHlV8njX5A\$I5Mm/64DORArcXYTXWRVng'">>/root/.jupyter/jupyter_notebook_config.py
+
+
+# RUN mkdir -p /data && echo "\
+# [program:jupyter]\n\
+# directory=/data\n\
+# command=/opt/conda/bin/jupyter lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser \n\
+# autorestart=true\n\
+# startretries=0\n\
+# redirect_stderr=true\n\
+# stdout_logfile=/dev/stdout\n\
+# stdout_logfile_maxbytes=0\n\
+# " > /etc/supervisor/conf.d/jupyter.conf
+
+# EXPOSE 8888

+ 15 - 0
Makefile

@@ -0,0 +1,15 @@
+NAME=datax-admin
+VERSION=latest
+BUILD_TIME      := $(shell date "+%F %T")
+COMMIT_SHA1     := $(shell git rev-parse HEAD)
+AUTHOR          := $(shell git show -s --format='%an')
+
+
+.PHONY: image
+
+all: image publish
+image:
+	@docker build -t registry.cn-hangzhou.aliyuncs.com/sxtest/$(NAME):$(VERSION) .
+
+publish:
+	@docker push registry.cn-hangzhou.aliyuncs.com/sxtest/$(NAME):$(VERSION)

+ 16 - 0
README.md

@@ -0,0 +1,16 @@
+# Datax Admin
+
+用于 dag 平台:
+
+- 数据源管理
+- 任务管理
+- 用户管理
+- 权限管理
+
+## 启动
+
+```shell
+conda env create environment.yml
+conda activate py38
+python run.py
+```

+ 16 - 0
docker-compose.yml

@@ -0,0 +1,16 @@
+version: '2'
+services:
+  datax-admin:
+    hostname: datax-admin
+    container_name: datax-admin
+    restart: always
+    image: registry.cn-hangzhou.aliyuncs.com/sxtest/datax-admin:latest
+    privileged: true
+    ipc: host
+    tty: true
+    working_dir: /workspace
+    ports:
+      - '18082:8080'
+      - '18224:22'
+    volumes:
+      - ./:/workspace

+ 34 - 0
environment.yml

@@ -0,0 +1,34 @@
+name: py38
+channels:
+  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ # Anocanda清华镜像
+  - defaults
+  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
+dependencies:
+  - python=3.8
+  - ipython
+  - sasl=0.3.1
+  - pip
+  - pip:
+      - cmake
+      - cython
+      - fastapi
+      - uvicorn
+      - pytest
+      - jinja2
+      - aiofiles
+      - python-multipart
+      - requests
+      - gunicorn
+      - fastapi-pagination==0.9.3
+      - pymysql==1.0.2
+      - PyHive==0.6.5
+      - pure-sasl==0.6.2
+      # - sasl==0.3.1
+      - thrift==0.16.0
+      - thrift-sasl==0.4.3
+      - mysql-connector==2.2.9
+      - SQLAlchemy==1.4.9
+      - numpy
+      - pandas
+      - -i https://mirror.baidu.com/pypi/simple
+prefix: /opt/conda/envs/py38