-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfileSmartTag
executable file
·57 lines (40 loc) · 1.7 KB
/
DockerfileSmartTag
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
FROM python:3.7-slim-buster AS base-compile-image
# amd64 or arm64, for example
ARG TARGETARCH
RUN apt-get update
# Set up the virtualenv that is copied to the build-image
RUN python -m venv /opt/venv
# Make sure we use the virtualenv:
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --upgrade pip
RUN pip install torch==1.10
RUN pip install python-dotenv==0.15.0
# The normal tensorflow package doesn't run on ARM, we need a special version for that.
# The blocks below acts basically like an if-else statement:
# if (ARM) install tensorflow-aarch64
# elif (x86) install tensorflow
# else fail
FROM base-compile-image AS compile-image-arm64
ENV TENSORFLOW_PACKAGE=tensorflow-aarch64==2.8.0
# Install a rust compiler, which is required to build the tokenizers package from source on the arm64 arch.
# tokenizers is a dependency of transformers, which we're installing below.
RUN apt-get install curl build-essential -y
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
FROM base-compile-image AS compile-image-amd64
ENV TENSORFLOW_PACKAGE=tensorflow==2.4.0
FROM compile-image-${TARGETARCH} AS compile-image
RUN pip install transformers==4.15.0
RUN pip install ${TENSORFLOW_PACKAGE}
FROM python:3.7-slim-buster AS build-image
COPY --from=compile-image /opt/venv /opt/venv
# Make sure we use the virtualenv:
ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /app
RUN mkdir /app/smtag
COPY ./pipeline.py /app/smtag/pipeline.py
COPY ./xml2labels.py /app/smtag/xml2labels.py
COPY ./cli/inference/tag.py /app/smtag/cli/inference/tag.py
COPY ./__init__.py /app/smtag/__init__.py
COPY ./cli/__init__.py /app/smtag/cli/__init__.py
COPY ./cli/inference/__init__.py /app/smtag/cli/inference/__init__.py