forked from opsdroid/opsdroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
67 lines (56 loc) · 1.71 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
FROM python:3.9.6-alpine3.14 as builder
LABEL maintainer="Jacob Tomlinson <[email protected]>"
WORKDIR /usr/src/app
ARG EXTRAS=[all,connector_matrix_e2e]
ENV DEPS_DIR=/usr/src/app/deps
# Copy source
COPY . .
# Install build tools and libraries to build OpsDroid and its dependencies.
RUN apk update \
&& apk add \
build-base \
cargo \
gcc \
git \
g++ \
libffi-dev \
linux-headers \
musl-dev \
olm-dev \
openssh-client \
openssl-dev \
python3-dev \
zeromq-dev \
&& pip install --upgrade \
build \
pip \
setuptools \
setuptools-scm \
wheel \
&& mkdir -p "${DEPS_DIR}" \
&& pip download --prefer-binary -d ${DEPS_DIR} .${EXTRAS} \
&& pip wheel -w ${DEPS_DIR} ${DEPS_DIR}/*.tar.gz \
&& count=$(ls -1 ${DEPS_DIR}/*.zip 2>/dev/null | wc -l) && if [ $count != 0 ]; then pip wheel -w ${DEPS_DIR} ${DEPS_DIR}/*.zip ; fi \
&& python -m build --wheel --outdir ${DEPS_DIR}
FROM python:3.9.6-alpine3.14 as runtime
LABEL maintainer="Jacob Tomlinson <[email protected]>"
LABEL maintainer="Rémy Greinhofer <[email protected]>"
WORKDIR /usr/src/app
ARG EXTRAS=[all,connector_matrix_e2e]
ENV DEPS_DIR=/usr/src/app/deps
# Copy the pre-built dependencies.
COPY --from=builder ${DEPS_DIR}/*.whl ${DEPS_DIR}/
# Install Opsdroid using only pre-built dependencies.
RUN apk add --no-cache \
git \
olm \
libzmq \
&& pip install --no-cache-dir --no-index -f ${DEPS_DIR} \
$(find ${DEPS_DIR} -type f -name opsdroid-*-any.whl)${EXTRAS} \
&& rm -rf /tmp/* /var/tmp/* ${DEPS_DIR}/* \
&& adduser -u 1001 -D opsdroid
EXPOSE 8080
# Ensure the service runs as an unprivileged user.
USER opsdroid
ENTRYPOINT ["opsdroid"]
CMD ["start"]