-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathDockerfile
135 lines (104 loc) · 3.84 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
FROM python:3.10.11 as base
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN apt update -y
RUN apt install --reinstall build-essential -y
# Decode raw protobuf message while parse some resources
RUN apt install -y protobuf-compiler
# Setup tesseract
RUN apt install -y tesseract-ocr tesseract-ocr-eng
RUN find / -name "tessdata" | grep tesseract | head -n 1 | xargs -I {} wget --quiet -O "{}/eng.traineddata" https://raw.githubusercontent.com/tesseract-ocr/tessdata/main/eng.traineddata
# Django bash completion
RUN apt install -y bash-completion
RUN wget -O /etc/bash_completion.d/django_bash_completion.sh https://raw.github.com/django/django/master/extras/django_bash_completion
RUN echo "if [ -f /etc/bash_completion ]; then . /etc/bash_completion; fi" >> ~/.bashrc
# Useful packages
RUN apt install -y lsof htop vim
# Setup python requirements
COPY --from=ghcr.io/astral-sh/uv:0.5.3 /uv /uvx /bin/
ENV UV_SYSTEM_PYTHON=1
ENV UV_LINK_MODE=copy
COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache/uv uv pip install -r requirements.txt
# Sentry CLI
RUN curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION="2.20.7" sh
# Curl
RUN wget https://github.com/stunnel/static-curl/releases/download/8.6.0-1/curl-linux-aarch64-8.6.0.tar.xz -O /tmp/curl.tar.xz && \
tar -xvf /tmp/curl.tar.xz -C /tmp && \
sha256sum /tmp/curl | grep -q "b42ad13ff77ea6baaacc2d560ace242ae449f8429ec47aa61ce3edd99879973c" && \
mv /tmp/curl /usr/local/bin/curl && \
rm /tmp/curl.tar.xz
# psql
RUN apt update --fix-missing && apt install -y postgresql-client
ENV APPDIR=/usr/src/clist
WORKDIR $APPDIR
FROM base as dev
ENV DJANGO_ENV_FILE .env.dev
RUN apt install -y redis-server
CMD sh -c 'redis-server --daemonize yes; scripts/watchdog.bash "python manage.py rqworker system default" "*.py"; python manage.py runserver 0.0.0.0:10042'
COPY config/ipython_config.py .
RUN ipython profile create
RUN cat ipython_config.py >> ~/.ipython/profile_default/ipython_config.py
RUN rm ipython_config.py
FROM base as prod
ENV DJANGO_ENV_FILE .env.prod
RUN apt install -y cron redis-server
COPY src/ $APPDIR/
COPY legacy/api/ $APPDIR/legacy/api/
COPY config/cron /etc/cron.d/clist
RUN chmod 0644 /etc/cron.d/clist
RUN crontab /etc/cron.d/clist
COPY config/uwsgi.ini $APPDIR/
RUN mkdir /run/daphne
COPY config/redis.conf /etc/redis/redis.conf
COPY config/supervisord.conf /etc/supervisord.conf
CMD supervisord -c /etc/supervisord.conf
FROM ubuntu:latest as loggly
RUN apt-get update && apt-get install -y rsyslog
RUN sed -i '/imklog/s/^/# /g' /etc/rsyslog.conf
COPY config/loggly/entrypoint.sh /entrypoint.sh
COPY config/loggly/60-loggly.conf /etc/rsyslog.d/60-loggly.conf
ENTRYPOINT /entrypoint.sh
FROM nginx:stable-alpine as nginx
# logrotate
RUN apk add --no-cache logrotate
COPY config/nginx/logrotate.d/nginx /etc/logrotate.d/nginx
RUN chmod 0644 /etc/logrotate.d/nginx
# cron
RUN apk add --no-cache logrotate dcron
COPY config/nginx/cron /etc/cron.d/nginx
RUN chmod 0644 /etc/cron.d/nginx
RUN crontab /etc/cron.d/nginx
CMD crond && nginx -g "daemon off;"
FROM postgres:14.3-alpine as postgres
# pg_repack
RUN apk add --no-cache --virtual .build-deps \
gcc \
g++ \
make \
musl-dev \
postgresql-dev \
git \
lz4-dev \
zlib-dev \
bash \
util-linux \
gawk
RUN cd /tmp \
&& git clone --depth 1 --branch ver_1.5.1 https://github.com/reorg/pg_repack.git \
&& cd pg_repack \
&& make \
&& make install \
&& apk del .build-deps \
&& rm -rf /tmp/pg_repack
# numfmt
RUN apk add --no-cache coreutils
# cron
RUN apk add --no-cache dcron
COPY config/postgres/cron /etc/cron.d/postgres
RUN chmod 0644 /etc/cron.d/postgres
RUN crontab /etc/cron.d/postgres
# supervisord
RUN apk add --no-cache supervisor
COPY config/postgres/supervisord.conf /etc/supervisord.conf
CMD supervisord -c /etc/supervisord.conf