alpine 编译java和python的基础镜像Dockerfile

## BUILD_IMAGE_NAME 为 build stage 所编译出来包含 *.pyc 的 docker image

ARG ARG_JAVA_BUILD_IMAGE_NAME

ARG ARG_PYTHON_BUILD_IMAGE_NAME

FROM ${ARG_JAVA_BUILD_IMAGE_NAME} AS java-build

FROM ${ARG_PYTHON_BUILD_IMAGE_NAME} AS python-build

FROM openjdk:8u212-jdk-alpine3.9

USER root

#更新下载库

RUN echo "http://mirrors.aliyun.com/alpine/v3.9/main/" > /etc/apk/repositories

RUN echo "http://mirrors.aliyun.com/alpine/v3.9/community/" >> /etc/apk/repositories

#安装bash,支持命令行

RUN apk update \

        && apk upgrade \

        && apk add --no-cache bash\

        bash-doc \

        bash-completion \

        && rm -rf /var/cache/apk/* \

        && /bin/bash   \

        && apk add -U tzdata curl

ENV TZ=Asia/Shanghai

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#安装uwsgi需要gcc环境

RUN apk add --no-cache gcc g++ make libc-dev linux-headers pcre-dev

RUN apk add --no-cache python3 python3-dev && \

    python3 -m ensurepip && \

    rm -r /usr/lib/python*/ensurepip && \

    pip3 install --upgrade pip setuptools && \

    if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \

    if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \

    rm -r /root/.cache

RUN apk add -f --no-cache openblas=0.3.3-r2 openblas-dev=0.3.3-r2 lapack=3.8.0-r1  lapack-dev=3.8.0-r1

#安装nginx

RUN apk add --no-cache nginx && mkdir /run/nginx/

#hdf5在edge分支的testing下

RUN apk add --no-cache --allow-untrusted --repository http://dl-3.alpinelinux.org/alpine/edge/testing hdf5 hdf5-dev

RUN pip3 install --upgrade pip -i https://pypi.douban.com/simple

RUN pip3 install Cython --install-option="--no-cython-compile" -i https://pypi.douban.com/simple --no-cache-dir

RUN pip3 install numpy -i https://pypi.douban.com/simple

RUN pip3 install -i http://mirrors.aliyun.com/pypi/simple/ \

    --trusted-host mirrors.aliyun.com \

    --no-cache-dir \

    python-pcre \

    scipy \

    uwsgi \

    # gensim \

    # sklearn \

    # gunicorn \

    gevent \

    lru-dict \

    h5py \

    Flask==0.10.1 \

    requests \

    datadog \

    # keras==2.0.8 \

    pydisque==0.1.2 \

    Cython \

    fasttext==0.8.3  \

    minio

    # jieba

WORKDIR /usr/src/app

#ENV SNLU_VER 0.0.4-SNAPSHOT

# COPY . /usr/src/app

COPY ./nginx.conf /etc/nginx

COPY health-check.sh health-check.sh

RUN touch /tmp/service.sock

#从其他镜像拷贝文件

COPY --from=java-build /usr/bin/app/ ./

COPY --from=python-build /usr/bin/app ./

#ENV PYTHONPATH /usr/bin/app

COPY entrypoint.sh ./entrypoint.sh

ENV LANG en_US.utf8

# 配置health策略

HEALTHCHECK --start-period=150s --interval=20s --timeout=5s --retries=3 CMD ./health-check.sh

ENTRYPOINT ["/usr/src/app/entrypoint.sh"]

 

你可能感兴趣的:(docker,alpine,java,python,numpy,scipy)