Dockerfile 2.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# 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.

15 16
FROM python:3.7-alpine3.10

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

19 20
WORKDIR /root

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

VOLUME /root/.cache

25 26 27
RUN apk update

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

ARG package

RUN if [ "$package" ]; then \
chen.zhiyu's avatar
chen.zhiyu 已提交
33
        set -e; \
34 35 36 37 38 39 40 41 42 43 44 45 46 47
        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 已提交
48
        set -e; \
49 50 51 52
        echo "$requirement" | base64 -d - > "requirement.txt"; \
        echo ">>> decode requirement:"; \
        cat "requirement.txt"; \
        echo ">>> install python requirement:"; \
chen.zhiyu's avatar
chen.zhiyu 已提交
53
        PIP_ARGS="--timeout 300"; \
54 55 56 57 58 59 60 61 62 63 64 65 66 67
        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
68 69 70


ENTRYPOINT [ "/bin/sh" ]