-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added correct consul template configuration
- Loading branch information
Showing
4 changed files
with
60 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,30 @@ | ||
FROM nginx:1.23 | ||
ARG CONSUL_TEMPLATE_VERSION=0.30.0 | ||
# we define an environment variable with the location of our Consul cluster. By default, it will try to resolve to | ||
# consul-client:8500 which would be the behavior if we have Consul running as a container in the same host and we link it to this | ||
# Nginx container (with the alias consul, of course). But this environment variable can also be overridden when we run the | ||
# container if we want to point somewhere else. | ||
ENV CONSUL_URL consul-client:8500 | ||
|
||
# download the latest version of Consul Template and we put it on /usr/local/bin | ||
ADD https://releases.hashicorp.com/consul-template/${CONSUL_TEMPLATE_VERSION}/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip /usr/bin/ | ||
RUN unzip /usr/bin/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip && \ | ||
mv consul-template /usr/local/bin/consul-template && \ | ||
rm -rf /usr/bin/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip | ||
|
||
|
||
COPY nginx.conf /etc/nginx/nginx.conf | ||
FROM nginx:1.23.1 | ||
|
||
ARG CONSUL_TEMPLATE_VERSION=0.30.0 | ||
|
||
# Set an environment variable for the location of the Consul | ||
# cluster. By default, it tries to resolve to consul-client:8500 | ||
# which is the behavior if Consul is running as a container in the | ||
# same host and linked to this NGINX container (with the alias | ||
# consul, of course). But this environment variable can also be | ||
# overridden as the container starts if we want to resolve to | ||
# another address. | ||
|
||
ENV CONSUL_URL consul-client:8500 | ||
|
||
# Download the specified version of Consul template | ||
ADD https://releases.hashicorp.com/consul-template/${CONSUL_TEMPLATE_VERSION}/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip /tmp | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends dumb-init unzip \ | ||
&& unzip /tmp/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip -d /usr/local/bin \ | ||
&& rm -rf /tmp/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip | ||
|
||
COPY consul-template-config.hcl ./consul-template-config.hcl | ||
COPY nginx.ctmpl /usr/templates/nginx.ctmpl | ||
|
||
EXPOSE 8085 | ||
|
||
STOPSIGNAL SIGQUIT | ||
|
||
CMD ["dumb-init", "consul-template", "-config=consul-template-config.hcl"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
consul { | ||
address = "consul-client:8500" | ||
|
||
retry { | ||
enabled = true | ||
attempts = 12 | ||
backoff = "250ms" | ||
} | ||
} | ||
template { | ||
source = "/usr/templates/nginx.ctmpl" | ||
destination = "/etc/nginx/conf.d/default.conf" | ||
perms = 0600 | ||
command = "if [ -e /var/run/nginx.pid ]; then nginx -s reload; else nginx; fi" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
upstream messenger_service { | ||
{{- range service "messenger" }} | ||
server {{ .Address }}:{{ .Port }}; | ||
{{- end }} | ||
} | ||
|
||
server { | ||
listen 8085; | ||
server_name localhost; | ||
|
||
location / { | ||
proxy_pass http://messenger_service; | ||
add_header Upstream-Host $upstream_addr; | ||
} | ||
} |