Dockerfile 2.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
14
ARG PYTHON_VERSION=3.7
15

16
FROM python:${PYTHON_VERSION}-alpine3.11
17

chen.zhiyu's avatar
chen.zhiyu 已提交
18 19
USER root

20 21
WORKDIR /root

chen.zhiyu's avatar
chen.zhiyu 已提交
22 23 24 25
VOLUME /root/.ccache

VOLUME /root/.cache

26 27 28
RUN apk update

RUN apk add --no-cache \
29 30 31 32 33
    g++ gfortran make cmake patchelf git ccache

ARG package

RUN if [ "$package" ]; then \
chen.zhiyu's avatar
chen.zhiyu 已提交
34
        set -e; \
35 36 37 38 39 40 41 42 43 44 45 46 47 48
        pkgs=$(echo "$package" | base64 -d -); \
        echo ">>> decode package:"; \
        echo "$pkgs"; \
        for nm in $pkgs; do \
            echo ">>> intall package: $nm"; \
            apk add --no-cache --force-overwrite "$nm"; \
        done; \
    fi

ARG requirement
ARG requirement_ut
ARG pip_index

RUN if [ "$requirement" ]; then \
chen.zhiyu's avatar
chen.zhiyu 已提交
49
        set -e; \
50 51 52 53
        echo "$requirement" | base64 -d - > "requirement.txt"; \
        echo ">>> decode requirement:"; \
        cat "requirement.txt"; \
        echo ">>> install python requirement:"; \
chen.zhiyu's avatar
chen.zhiyu 已提交
54
        PIP_ARGS="--timeout 300"; \
55 56 57 58 59 60 61 62 63 64 65 66 67 68
        if [ "$pip_index" ]; then \
            PIP_DOMAIN=$(echo "$pip_index" | awk -F/ '{print $3}'); \
            PIP_ARGS="$PIP_ARGS -i $pip_index --trusted-host $PIP_DOMAIN"; \
            echo ">>> pip index: $pip_index"; \
        fi; \
        pip3 install $PIP_ARGS -r "requirement.txt"; \
        rm -f "requirement.txt"; \
        if [ "$requirement_ut" ]; then \
            echo "$requirement_ut" | base64 -d - > "requirement_ut.txt"; \
            cat "requirement_ut.txt"; \
            pip3 install $PIP_ARGS -r "requirement_ut.txt"; \
            rm -f "requirement_ut.txt"; \
        fi; \
    fi
69 70 71


ENTRYPOINT [ "/bin/sh" ]