forked from taranis-ai/taranis-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.worker
46 lines (33 loc) · 1.2 KB
/
Dockerfile.worker
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
FROM python:3.11-slim as builder
WORKDIR /app/
RUN apt-get update && apt-get upgrade -y && \
apt-get install --no-install-recommends -y \
build-essential \
python3-dev \
libglib2.0-0 \
libpango-1.0-0 \
libpangoft2-1.0-0 \
git
COPY ./src/worker/. /app/
RUN python3 -m venv /app/.venv && \
export PATH="/app/.venv/bin:$PATH" && \
pip install --no-cache-dir --upgrade pip wheel && \
pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch && \
pip install --no-cache-dir -e /app/
FROM python:3.11-slim
WORKDIR /app
RUN apt-get update && apt-get upgrade -y && \
apt-get install --no-install-recommends -y \
libpango-1.0-0 \
libpangoft2-1.0-0
RUN groupadd user && useradd --home-dir /app -g user user && chown -R user:user /app
USER user
COPY --from=builder --chown=user:user /app/.venv /app/.venv
COPY --from=builder /usr/lib/x86_64-linux-gnu/* /usr/lib/x86_64-linux-gnu/
COPY --chown=user:user ./src/worker/. /app/
ENV PYTHONPATH=/app
ENV PATH="/app/.venv/bin:$PATH"
# bake spacy modell into Image
RUN python -c 'from worker.bots.nlp_bot import NLPBot; n = NLPBot()'
ENTRYPOINT [ "celery" ]
CMD ["--app", "worker", "worker"]