-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Dockerfile
78 lines (66 loc) · 1.64 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
# Build Go programs (only corrupter at the moment)
FROM golang:1-alpine AS go-build
RUN apk add --no-cache git
RUN go get github.com/r00tman/corrupter
# Build Python package and dependencies
FROM python:3-alpine AS python-build
RUN apk add --no-cache \
git \
libffi-dev \
musl-dev \
gcc \
g++ \
leveldb-dev \
make \
zlib-dev \
tiff-dev \
freetype-dev \
libpng-dev \
libjpeg-turbo-dev \
lcms2-dev \
libwebp-dev \
openssl-dev \
cargo
RUN mkdir -p /opt/venv
WORKDIR /opt/venv
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN mkdir -p /src
WORKDIR /src
# Install bot package and dependencies
COPY . .
RUN pip install wheel
RUN pip install .[fast]
RUN pip install uvloop
# Package everything
FROM python:3-alpine AS final
# Install optional native tools (for full functionality)
RUN apk add --no-cache neofetch
# Install native dependencies
RUN apk add --no-cache \
libffi \
leveldb \
zlib \
tiff \
freetype \
libpng \
libjpeg-turbo \
lcms2 \
libwebp
# Create bot user
RUN adduser -D pyrobud
# Create data directory for the bot user
RUN mkdir -p /data
RUN chown pyrobud:pyrobud /data
# Ensure we a volume is mounted even if the user doesn't explicitly specify it,
# to prevent unintentional data loss
VOLUME [ "/data" ]
# Copy Go programs
COPY --from=go-build /go/bin/corrupter /usr/local/bin
# Copy Python venv
ENV PATH="/opt/venv/bin:$PATH"
COPY --from=python-build /opt/venv /opt/venv
# Set runtime settings
USER pyrobud
WORKDIR /data
CMD ["pyrobud"]