-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile.worker.python
58 lines (48 loc) · 2.72 KB
/
Dockerfile.worker.python
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
# syntax=docker/dockerfile:1.9.0
# NOTE(frank): This Dockerfile is NOT optimized for caching. Rather, it's optimized
# for the smallest possible image size via the fewest layers.
# If you update the python version or base image, ensure that the site-packages
# path in scripts/add-lib.sh is correct.
FROM ghcr.io/superblocksteam/python:3.10.14-slim-bookworm
# NOTE(frank): We do not want this message printed to STDOUT
# UserWarning: slack package is deprecated. Please use slack_sdk.web/webhook/rtm package instead. For more info, go to https://slack.dev/python-slack-sdk/v3-migration/
#
# https://github.com/slackapi/python-slack-sdk/blob/7e71b7377a9f0e627f0da45fd5a74fe6117b7cbc/slack/deprecation.py#L6C40-L6C68
#
ENV SLACKCLIENT_SKIP_DEPRECATION true
ENV NODE_VERSION 16.x
ARG EXTRA_DEBIAN_PACKAGES
WORKDIR /usr/app/worker-python
COPY ./workers/python/requirements.txt /usr/app/worker-python/
COPY ./workers/python/src/ /usr/app/worker-python/src/
# NOTE(frank): Our goal is to keep STDOUT clean. By reverse engineering the source code, we can see that
# by write this file to disk, the import of this dependency will not log the creation of a file.
COPY ./workers/python/canalyst.json /root/canalyst/keys.json
RUN set -ex; \
pip install --upgrade pip && \
pip install --upgrade setuptools && \
groupadd --gid 1000 node && \
useradd --uid 1000 --gid node --shell /bin/bash --create-home node && \
apt-get update && \
apt-get install -yqq gcc gnupg libc6-dev libpq-dev wget dnsutils iputils-ping curl build-essential cmake --no-install-recommends && \
curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.asc && \
curl https://packages.microsoft.com/config/debian/12/prod.list | tee /etc/apt/sources.list.d/mssql-release.list && \
echo "deb [arch=amd64,arm64,armhf] https://packages.microsoft.com/debian/12/prod bookworm main" > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get install -y msodbcsql18 ${EXTRA_DEBIAN_PACKAGES} && \
rm -rf /var/lib/apt/lists/* && \
pip3 install -r requirements.txt && \
chmod -R u=rwx,go=rx /usr/app/worker-python
# this will fail if theres a dif
# this is how we can ensure the requirements file stays accurate with transitive deps
RUN pip freeze > freeze.txt && \
sed 's/-/_/g' freeze.txt > tmpfile && mv tmpfile freeze.txt && \
if diff -q requirements.txt freeze.txt; then \
rm freeze.txt; \
else \
echo "Differences found between requirements.txt and freeze.txt:"; \
echo "Contents of requirements.txt:" && cat requirements.txt; \
diff requirements.txt freeze.txt; \
exit 1; \
fi
CMD [ "python3", "/usr/app/worker-python/src/entry.py"]