forked from Helsinki-NLP/Opus-MT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.base
68 lines (54 loc) · 2.58 KB
/
Dockerfile.base
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
63
64
65
66
67
68
# This is a two-stage Docker build where we use a more fully featured Debian
# image to build Marian and the required Python modules, then copy the built
# artifacts into a much smaller final image.
FROM debian:buster as builder
WORKDIR /usr/src/app
# Install base packages
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates git wget gnupg build-essential lsb-release g++ \
automake autogen libtool cmake-data cmake unzip \
libboost-all-dev libblas-dev libopenblas-dev libz-dev libssl-dev \
libprotobuf17 protobuf-compiler libprotobuf-dev \
python3-dev python3-pip python3-setuptools python3-websocket python3-venv;
# Install Intel libraries
RUN set -eux; \
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB; \
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB; \
sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list';\
apt-get update; \
apt-get install -y --no-install-recommends \
intel-mkl-64bit-2019.5-075; \
rm -f GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB;
# Build Marian, using static libraries so we can simply pluck the compiled
# marian-server out later
RUN set -eux; \
git clone https://github.com/marian-nmt/marian marian; \
cd marian; \
git checkout 1.9.0; \
cmake . -DUSE_STATIC_LIBS=on -DCOMPILE_SERVER=on -DUSE_SENTENCEPIECE=on -DCOMPILE_CPU=on -DCOMPILE_CUDA=off -DAVX512_FOUND=false; \
make -j4 marian_server ;
COPY requirements.txt .
# Install python requirements. First we upgrade to the latest pip so it can
# support "manylinux2014" binary wheels.
# First wheel, because the others won't work without it set up.
RUN set -eux; \
python3 -mvenv venv ; venv/bin/pip install --upgrade pip ; \
venv/bin/pip install -r requirements.txt
# Start over from the minimal "slim" python base image
FROM python:3.7-slim-buster
WORKDIR /usr/src/app
# Include just the marian-server binary and the Python virtual environment from
# the build image - we don't need all the Marian sources, intermediate build
# artifacts, other Marian binaries, MKL libraries, etc.
COPY --from=builder /usr/src/app/marian/marian-server /usr/local/bin
COPY --from=builder /usr/src/app/venv /usr/src/app/venv/
# Install perl modules required by moses, and fix up the venv as python is
# in a different place in the "python" base image compared to where apt
# installs it in debian:stable
RUN set -ex ; \
apt-get update; \
apt-get install -y --no-install-recommends perl ; \
rm -rf /var/lib/apt/lists/* ; \
ln -sf /usr/local/bin/python3 /usr/src/app/venv/bin/python3