-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.local_deploy
75 lines (60 loc) · 2.12 KB
/
Dockerfile.local_deploy
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
#Build stage 0
FROM erlang:24 as base
ENV DOG_AGENT_VERSION=local_docker
ENV DOG_AGENT_BROKER_USERNAME=guest
ENV DOG_AGENT_BROKER_PASSWORD=guest
ENV DOG_AGENT_BROKER_VIRTUAL_HOST=dog
ENV DOG_AGENT_BROKER_HOST=rabbitmq
ENV DOG_AGENT_BROKER_PORT=5673
ENV DOG_AGENT_CACERTFILE=/etc/dog/certs/ca.crt
ENV DOG_AGENT_CERTFILE=/etc/dog/certs/server.crt
ENV DOG_AGENT_KEYFILE=/etc/dog/private/server.key
RUN apt-get update && apt-get install -y libcap-dev iptables ipset less ack lsb-release vim jq curl dnsutils netcat
#Set working directory
RUN mkdir /data
WORKDIR /data
COPY rebar.config rebar.config
COPY rebar.lock .
COPY rebar3 .
RUN ./rebar3 deps
RUN ./rebar3 compile
FROM base as compile
WORKDIR /data
COPY . .
COPY --from=base /data/_build .
#COPY config/sys.config.etc config/sys.config
#RUN rm config/sys.config
COPY config/sys.config.src config/sys.config.src
#RUN sed -i 's/NOT_SET/local_docker/g' config/sys.config
RUN ./rebar3 --version
#Build the release
RUN ./rebar3 release as local_docker
FROM base as deploy
RUN mkdir -p /opt/dog
RUN mkdir -p /etc/dog
RUN mkdir -p /etc/iptables
#COPY config/sys.config.local_docker /etc/dog/dog.config
COPY config/config.json.local_docker /etc/dog/config.json
RUN mkdir -p /var/log/dog
# Install the released application
COPY --from=compile /data/_build/default/rel/dog /opt/dog
RUN ls /opt/dog/lib
RUN chmod 4555 /opt/dog/lib/erlexec-*/priv/x86_64-pc-linux-gnu/exec-port
RUN mkdir -p /home/dog/bin
RUN cp /usr/sbin/ipset /home/dog/bin/ipset
RUN cp /usr/sbin/iptables-save /home/dog/bin/
RUN cp /usr/sbin/ip6tables-save /home/dog/bin/
RUN cp /usr/sbin/iptables-restore /home/dog/bin/
RUN cp /usr/sbin/ip6tables-restore /home/dog/bin/
RUN ls -latr /opt/dog
RUN mkdir /etc/rabbitmq
COPY csc_certs.sh /etc/rabbitmq/
RUN mkdir -p /etc/dog/certs \
&& mkdir -p /etc/dog/private \
&& chmod 700 /etc/dog/private
RUN tar czf /tmp/dog_agent.tar.gz /opt/dog
FROM scratch AS tar
COPY --from=deploy /tmp/dog_agent.tar.gz /
FROM deploy as run
CMD /bin/bash -c "/etc/rabbitmq/csc_certs.sh" && /bin/bash -c "/opt/dog/bin/dog foreground"
#CMD /bin/bash -c "/etc/rabbitmq/csc_certs.sh" && /bin/bash -c "sleep infinity"