forked from matrix-org/sydent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (48 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
59
#
# Step 1: Build sydent and install dependencies
#
FROM docker.io/python:3.8-alpine as builder
# Install dev packages
RUN apk add --no-cache \
build-base \
libressl-dev \
libffi-dev
# Add user sydent
RUN addgroup -S -g 993 sydent \
&& adduser -D --home /sydent -S -u 993 -G sydent -s /bin/ash sydent \
&& echo "sydent:$(dd if=/dev/random bs=32 count=1 | base64)" | chpasswd
# Copy resources
COPY --chown=sydent:sydent ["res", "/sydent/res"]
COPY --chown=sydent:sydent ["scripts", "/sydent/scripts"]
COPY --chown=sydent:sydent ["sydent", "/sydent/sydent"]
COPY --chown=sydent:sydent ["README.rst", "setup.cfg", "setup.py", "/sydent/"]
# Install dependencies
RUN cd /sydent \
&& su sydent -c 'pip install --user --upgrade pip setuptools sentry-sdk' \
&& su sydent -c 'pip install --user -e .' \
&& rm -rf /sydent/.cache \
&& find /sydent -name '*.pyc' -delete
#
# Step 2: Reduce image size and layers
#
FROM docker.io/python:3.8-alpine
# Install packages
RUN apk add --no-cache \
libressl \
libffi
# Add user sydent and create /data directory
RUN addgroup -S -g 993 sydent \
&& adduser -D --home /sydent -S -u 993 -G sydent -s /bin/ash sydent \
&& echo "sydent:$(dd if=/dev/random bs=32 count=1 | base64)" | chpasswd \
&& mkdir /data \
&& chown sydent:sydent /data
# Copy sydent
COPY --from=builder ["/sydent", "/sydent"]
ENV SYDENT_CONF=/data/sydent.conf
ENV SYDENT_PID_FILE=/data/sydent.pid
ENV SYDENT_DB_PATH=/data/sydent.db
WORKDIR /sydent
USER sydent:sydent
VOLUME ["/data"]
EXPOSE 8090/tcp
CMD [ "python", "-m", "sydent.sydent" ]