Skip to content

Commit af1aa9c

Browse files
committed
Add confd support
1 parent 139fc67 commit af1aa9c

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ MAINTAINER Justin Menga <[email protected]>
33
LABEL application=microtrader
44

55
# Install system dependencies
6-
RUN apk add --update --no-cache bash curl
6+
RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories && \
7+
apk add --update --no-cache bash curl confd@testing
78

89
# Create vertx user
9-
RUN mkdir /app && \
10+
RUN mkdir -p /app/conf && \
1011
addgroup -g 1000 vertx && \
1112
adduser -u 1000 -G vertx -D vertx && \
1213
chown -R vertx:vertx /app
@@ -15,8 +16,10 @@ RUN mkdir /app && \
1516
USER vertx
1617
WORKDIR /app
1718

19+
# Copy common confd templates
20+
COPY etc/confd /etc/confd
21+
1822
# Set entrypoint and default command arguments
19-
COPY cluster.xml /app/conf/cluster.xml
2023
COPY entrypoint.sh /app/entrypoint.sh
2124
ENTRYPOINT ["/app/entrypoint.sh"]
2225
CMD ["java", "-jar", "/app/app.jar", "-server", "-cluster", "-Dvertx.hazelcast.config=/app/conf/cluster.xml"]

entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -e
33

44
# Add initialisation logic here
5+
confd -onetime -backend env
56

67
# Run application
78
exec "$@"

etc/confd/conf.d/cluster.xml.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[template]
2+
src = "cluster.xml.tmpl"
3+
dest = "/app/conf/cluster.xml"
4+
keys = [
5+
"/cluster/group/name",
6+
"/cluster/group/password",
7+
"/cluster/aws/enabled",
8+
"/cluster/aws/region",
9+
"/cluster/aws/iam/role",
10+
"/cluster/aws/tag/key",
11+
"/cluster/aws/tag/value",
12+
]

cluster.xml renamed to etc/confd/templates/cluster.xml.tmpl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
</properties>
1212

1313
<group>
14-
<name>microtrader</name>
15-
<password>password</password>
14+
<name>{{getv "/cluster/group/name" "microtrader"}}</name>
15+
<password>{{getv "/cluster/group/password" "password"}}</password>
1616
</group>
1717

1818
<management-center enabled="false">http://localhost:8080/mancenter</management-center>
1919
<network>
20-
<port auto-increment="true" port-count="10">5701</port>
20+
<port auto-increment="true" port-count="10000">5701</port>
2121
<outbound-ports>
2222
<!--
2323
Allowed port range when connecting to other nodes.
@@ -26,10 +26,21 @@
2626
<ports>0</ports>
2727
</outbound-ports>
2828
<join>
29+
{{- if eq (toLower (getv "/cluster/aws/enabled" "false")) "true" }}
30+
<multicast enabled="false"/>
31+
<tcp-ip enabled="false"/>
32+
<aws enabled="true">
33+
<region>{{getv "/cluster/aws/region" "us-west-2"}}</region>
34+
<iam-role>{{getv "/cluster/aws/iam/role" "DEFAULT"}}</iam-role>
35+
<tag-key>{{getv "/cluster/aws/tag/key" "hazelcast:group"}}</tag-key>
36+
<tag-value>{{getv "/cluster/aws/tag/value" "microtrader"}}</tag-value>
37+
</aws>
38+
{{- else }}
2939
<multicast enabled="true"/>
3040
<tcp-ip enabled="false">
3141
<interface>127.0.0.1</interface>
3242
</tcp-ip>
43+
{{- end }}
3344
</join>
3445
<interfaces enabled="false">
3546
<interface>10.10.1.*</interface>

0 commit comments

Comments
 (0)