-
Notifications
You must be signed in to change notification settings - Fork 151
/
Dockerfile
58 lines (44 loc) · 1.59 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
FROM python:3.9-alpine
LABEL maintainer=paul.traylor@linecorp.com
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PIP_NO_CACHE_DIR off
ENV PROMGEN_CONFIG_DIR=/etc/promgen
RUN adduser -D -u 1000 promgen promgen
# Upgrade Pip
RUN pip install --no-cache-dir -U pip~=23.2
# Install MySQL Support
RUN set -ex \
&& apk add --no-cache mariadb-dev \
&& apk add --no-cache --virtual build-deps build-base \
&& pip --no-cache-dir install mysqlclient \
&& apk del build-deps
# Install Postgres Support
RUN set -ex \
&& apk add --no-cache postgresql-dev \
&& apk add --no-cache --virtual build-deps build-base \
&& pip install --no-cache-dir psycopg2-binary \
&& apk del build-deps
RUN mkdir -p /etc/prometheus; \
mkdir -p /etc/promgen; \
mkdir -p /usr/src/app; \
chown promgen /etc/prometheus
# Get needed prometheus binaries
COPY --from=prom/prometheus:v2.26.0 /bin/promtool /usr/local/bin/promtool
COPY docker/requirements.txt /tmp/requirements.txt
RUN set -ex \
&& apk add --no-cache --virtual build-deps build-base libffi-dev \
&& pip install --no-cache-dir -r /tmp/requirements.txt \
&& apk del build-deps
COPY docker/docker-entrypoint.sh /
COPY pyproject.toml /usr/src/app/pyproject.toml
COPY promgen /usr/src/app/promgen
COPY promgen/tests/examples/promgen.yml /etc/promgen/promgen.yml
WORKDIR /usr/src/app
RUN pip install --no-cache-dir -e .
USER promgen
EXPOSE 8000
RUN SECRET_KEY=1 promgen collectstatic --noinput
VOLUME ["/etc/promgen", "/etc/prometheus"]
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["web", "--bind", "0.0.0.0:8000", "--workers", "4"]