FROM kevinwan/goctl as image-dev
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk update && apk add --no-cache make supervisor busybox-extras git gcc g++
RUN mkdir -p /etc/supervisor.d/


FROM kevinwan/goctl as builder
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk update && apk add --no-cache  supervisor busybox-extras git vim
ENV WORKDIR /app
WORKDIR ${WORKDIR}
RUN mkdir -p /etc/supervisor.d/ && mkdir -p /tmp/charts
COPY aihub-dag-jupyter /tmp/charts/aihub-dag-jupyter
RUN cd /tmp/charts && tar cvfz aihub-dag-jupyter.tgz aihub-dag-jupyter
ADD helmwrapper .
ADD config-example.yaml .
RUN chmod a+x helmwrapper
COPY dag-jupyter dag-jupyter
RUN cd dag-jupyter && go env -w GOPROXY=https://goproxy.cn,direct && go mod vendor && go build -o main

RUN echo -e "\
[program:be]\n\
directory=/app/dag-jupyter\n\
command=/app/dag-jupyter/main -f etc/jupyter-api.yaml\n\
autorestart=true\n\
startretries=1000\n\
redirect_stderr=true\n\
stdout_logfile=/var/log/be.log\n\
stdout_logfile_maxbytes=50MB\n\
" > /etc/supervisor.d/be.ini
EXPOSE 8080


RUN echo -e "\
[program:helm]\n\
directory=/app\n\
command=/app/helmwrapper --config /app/config-example.yaml --kubeconfig config.yaml --port 8081\n\
autorestart=true\n\
startretries=1000\n\
redirect_stderr=true\n\
stdout_logfile=/var/log/helm.log\n\
stdout_logfile_maxbytes=50MB\n\
;environment=GIN_MODE=release\n\
" > /etc/supervisor.d/helm.ini
EXPOSE 8081

ENTRYPOINT ["supervisord", "-n"]




FROM builder as image-sxkj
# kubeconfig
COPY config-sxkj.yaml config.yaml

FROM builder as image-idctest
# kubeconfig
COPY config-idctest.yaml config.yaml


FROM builder as image-txtest
# kubeconfig
COPY config-txtest.yaml config.yaml


FROM builder as image-txprod
# kubeconfig
COPY config-txprod.yaml config.yaml
