forked from CESARBR/knot-service-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
102 lines (80 loc) · 3.62 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
FROM n0madic/alpine-gcc:8.4.0 AS builder
# Build arguments
ARG JSONC_VERSION=0.14-20200419
ARG LIBELL_VERSION=0.17
ARG RABBITMQC_VERSION=v0.10.0
ARG KNOT_PROTOCOL_VERSION=KNOT-v03.00-rc04
ARG KNOT_CLOUD_SDK_VERSION=devel
ARG KNOT_HAL_VERSION=KNOT-v03.00-rc04
# Install dependencies
RUN apk update && apk add --no-cache \
wget \
pkgconfig \
autoconf \
automake \
libtool \
dbus dbus-dev \
glib-dev \
file \
git \
make
WORKDIR /usr/local
# Install json-c dependency
RUN mkdir -p /usr/local/jsonc
RUN wget -q -O- https://github.com/json-c/json-c/archive/json-c-$JSONC_VERSION.tar.gz | tar xz -C /usr/local/jsonc --strip-components=1
RUN cd jsonc && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make install
# Install libell
RUN mkdir -p /usr/local/ell
RUN wget -q -O- https://mirrors.edge.kernel.org/pub/linux/libs/ell/ell-$LIBELL_VERSION.tar.gz|tar xz -C /usr/local/ell --strip-components=1
RUN cd ell && ./configure --prefix=/usr && make install
# Install librabbitmq-c
RUN apk add --no-cache \
cmake openssl-dev
RUN mkdir -p /usr/local/rabbitmq-c
RUN wget -q -O- https://github.com/alanxz/rabbitmq-c/archive/$RABBITMQC_VERSION.tar.gz|tar xz -C /usr/local/rabbitmq-c --strip-components=1
RUN cd rabbitmq-c && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make install
# Install knot-protocol
RUN mkdir -p /usr/local/protocol
RUN wget -q -O- https://github.com/CESARBR/knot-protocol-source/archive/$KNOT_PROTOCOL_VERSION.tar.gz|tar xz -C /usr/local/protocol --strip-components=1
RUN cd protocol && ./bootstrap-configure && make install
# Install knot-cloud-sdk-c
RUN mkdir -p /usr/local/knot-cloud-sdk-c
RUN ls -h
RUN git clone https://github.com/ramonhpr/knot-cloud-sdk-c.git /usr/local/knot-cloud-sdk-c
RUN cd knot-cloud-sdk-c && git checkout $KNOT_CLOUD_SDK_VERSION && PKG_CONFIG_PATH=/usr/lib64/pkgconfig ./bootstrap-configure && make install
# Install knot-hal
RUN mkdir -p /usr/local/hal
RUN wget -q -O- https://github.com/CESARBR/knot-hal-source/archive/$KNOT_HAL_VERSION.tar.gz|tar xz -C /usr/local/hal --strip-components=1
RUN cd hal && PKG_CONFIG_PATH=/usr/lib64/pkgconfig ./bootstrap-configure && make install
# Copy files to source
COPY ./ ./
# Generate Makefile
RUN PKG_CONFIG_PATH=/usr/lib64/pkgconfig ./bootstrap-configure
# Build knotd and inetbrd
RUN make install
FROM alpine:3.10.3
ENV RABBITMQ_HOST rabbitmq
ENV RABBITMQ_PORT 5672
RUN apk add --no-cache dbus
WORKDIR /usr/local
# Copy shared files .so from builder to target image
COPY --from=builder /usr/lib/libell.so* /usr/lib/
COPY --from=builder /usr/lib64/libjson-c.so* /usr/lib/
COPY --from=builder /usr/lib/libknotprotocol.so* /usr/lib/
COPY --from=builder /usr/lib/libknotprotocol.a* /usr/lib/
COPY --from=builder /usr/lib/libhal.so* /usr/lib/
COPY --from=builder /usr/lib/libhal.a* /usr/lib/
COPY --from=builder /usr/lib/libknotcloudsdkc.so.* /usr/lib/
COPY --from=builder /usr/lib/libknotcloudsdkc.a* /usr/lib/
COPY --from=builder /usr/lib64/librabbitmq.so* /usr/lib/
COPY --from=builder /usr/lib64/librabbitmq.a* /usr/lib/
# Copy dbus configuration
COPY --from=builder /etc/dbus-1/system.d/ /etc/dbus-1/system.d/
# Copy knotd configuration
COPY --from=builder /usr/local/src/knotd.conf /etc/knot/knotd.conf
# Copy binary executables
COPY --from=builder /usr/local/src/knotd /usr/bin/knotd
COPY --from=builder /usr/local/inetbr/inetbrd /usr/bin/inetbrd
# system confiuration to allow tcp over dbus
COPY ./docker/system.conf /usr/share/dbus-1/system.conf
CMD mkdir -p /var/run/dbus/ && dbus-daemon --system && sleep 2 && (inetbrd -n & knotd -nr -R amqp://$RABBITMQ_HOST:$RABBITMQ_PORT)