This repository has been archived by the owner on Nov 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Dockerfile
107 lines (87 loc) · 2.27 KB
/
Dockerfile
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# global variables
ARG RASA_VERSION
ARG USER="rasa"
ARG HOME="/app"
ARG VENV="/opt/venv"
ARG UID=1001
ARG GID=1001
ARG PYTHON_VERSION="3.10"
FROM condaforge/mambaforge:latest as conda
RUN apt-get update \
&& apt-get install build-essential -y
# for confluent-kafka
# https://github.com/confluentinc/confluent-kafka-python/issues/1326#issuecomment-1228852754
RUN apt-get install -y --no-install-recommends gcc git libssl-dev g++ make && \
cd /tmp && git clone https://github.com/edenhill/librdkafka.git && \
cd librdkafka && git checkout tags/v1.9.0 && \
./configure && make && make install && \
cd ../ && rm -rf librdkafka
# use global variables
ARG USER
ARG HOME
ARG VENV
ARG UID
ARG GID
ARG RASA_VERSION
ARG PYTHON_VERSION
# create nonroot user with home directory ad /nonroot
RUN groupadd \
--gid $GID \
$USER \
&& useradd \
--uid $UID \
--gid $GID \
--create-home \
--home $HOME \
$USER \
&& chown -R $USER $HOME
WORKDIR $HOME
ARG ENV_FILE="env-$RASA_VERSION.yaml"
COPY ./requirements.txt ./
RUN pip install -r requirements.txt
COPY ./rasa_dc ./rasa_dc
RUN python -m rasa_dc \
--platform docker \
--python $PYTHON_VERSION \
--rasa_version $RASA_VERSION \
-d "." \
-f $ENV_FILE
# Create the virtual environment according to the env.yml file
COPY ./tensorflow-addons-aarch64/whl /tmp/tfa-whl
RUN conda env create \
--file=$ENV_FILE \
--prefix $VENV
RUN rm -rf /tmp/*
# make conda env default python env
ENV PATH="$VENV/bin:$PATH"
ENV LD_PRELOAD=/opt/venv/lib/python3.10/site-packages/scikit_learn.libs/libgomp-d22c30c5.so.1.0.0
# install Rasa without dependencies
RUN pip install --no-deps rasa==${RASA_VERSION}
USER $USER
FROM ubuntu:20.04 as runner
# use global variables
ARG USER
ARG HOME
ARG VENV
ARG UID
ARG GID
ARG RASA_VERSION
# create nonroot user with home directory at /nonroot
RUN groupadd \
--gid $GID \
$USER \
&& useradd \
--uid $UID \
--gid $GID \
--create-home \
--home $HOME \
$USER \
&& chown -R $USER $HOME
COPY --from=conda $VENV $VENV
# fix for scikit learn
ENV LD_PRELOAD=/opt/venv/lib/python3.10/site-packages/scikit_learn.libs/libgomp-d22c30c5.so.1.0.0
# make conda env default python env
ENV PATH="$VENV/bin:$PATH"
WORKDIR $HOME
USER $USER
ENTRYPOINT ["rasa"]