-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
69 lines (52 loc) · 2.14 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
# Base image is the Official HAProxy
FROM haproxy:2.2
# TODO: [GEN] Replace with your name and email
LABEL Jean-Luc Blanc <[email protected]>
LABEL Dylan Canton <[email protected]>
LABEL Christian Zaccaria <[email protected]>
# Install some tools
RUN apt-get update && apt-get -y install wget curl vim iputils-ping rsyslog xz-utils
# Download and install S6 overlay
RUN curl -sSLo /tmp/s6.tar.gz https://github.com/just-containers/s6-overlay/releases/download/v2.1.0.2/s6-overlay-amd64.tar.gz \
&& tar xzf /tmp/s6.tar.gz -C / \
&& rm -f /tmp/s6.tar.gz
# Install serf (for decentralized cluster membership: https://www.serf.io/)
RUN mkdir /opt/bin \
&& curl -sSLo /tmp/serf.gz https://releases.hashicorp.com/serf/0.8.2/serf_0.8.2_linux_amd64.zip \
&& gunzip -c /tmp/serf.gz > /opt/bin/serf \
&& chmod 755 /opt/bin/serf \
&& rm -f /tmp/serf.gz
# Install NodeJS
RUN curl -sSLo /tmp/node.tar.xz https://nodejs.org/dist/v14.15.1/node-v14.15.1-linux-x64.tar.xz \
&& tar -C /usr/local --strip-components 1 -xf /tmp/node.tar.xz \
&& rm -f /tmp/node.tar.xz
# Install the handlebars-cmd node module and its dependencies
RUN npm install -g handlebars-cmd
# Copy the S6 service and make the run script executable
COPY services/ha /etc/services.d/ha
RUN chmod +x /etc/services.d/ha/run
# Copy the Serf service and make the run scrip executable
COPY services/serf /etc/services.d/serf
RUN chmod +x /etc/services.d/serf/run
# Copy events handler scripts
RUN mkdir /serf-handlers
COPY scripts/* /serf-handlers/
RUN chmod +x /serf-handlers/*
# Copy the haproxy and syslog config
COPY config/haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
COPY config/rsyslogd.cfg /etc/rsyslog.d/49-haproxy.conf
# Copy the haproxy configuration template
RUN mkdir /config
COPY config/haproxy.cfg.hb /config/haproxy.cfg.hb
# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Create the nodes folder
RUN mkdir /nodes
# Expose the ports for Serf
EXPOSE 7946 7373
# Expose the HA proxy ports
EXPOSE 80 1936
# Define an environment variable
ENV ROLE balancer
# This will start S6 as our main process in our container
ENTRYPOINT ["/init"]