Dockerfile 2.0 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 17 18 19 20 21
FROM python:3.7-alpine3.10

WORKDIR /root

RUN apk update

RUN apk add --no-cache \
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
    g++ gfortran make cmake patchelf git ccache

VOLUME /root/.ccache

ARG package

RUN if [ "$package" ]; then \
        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 \
        echo "$requirement" | base64 -d - > "requirement.txt"; \
        echo ">>> decode requirement:"; \
        cat "requirement.txt"; \
        echo ">>> install python requirement:"; \
        PIP_ARGS="--timeout 300 --no-cache-dir"; \
        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"; \
            echo ">>> decode requirement_ut:"; \
            cat "requirement_ut.txt"; \
            pip3 install $PIP_ARGS -r "requirement_ut.txt"; \
            rm -f "requirement_ut.txt"; \
        fi; \
    fi
63 64 65


ENTRYPOINT [ "/bin/sh" ]