Last active
June 24, 2018 03:18
-
-
Save shouhei/afb6d564b6eb2f0be9e9c54e3af3c53c to your computer and use it in GitHub Desktop.
[Nomad] Use client side variables.
This file contains hidden or 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
| from flask import Flask | |
| import os | |
| app = Flask(__name__) | |
| @app.route("/", methods=["GET"]) | |
| def root(): | |
| return os.getenv("DOMAIN", "None") | |
| if __name__ == "__main__": | |
| app.run(host="0.0.0.0") |
This file contains hidden or 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
| client { | |
| enabled = true | |
| servers = [ "ipaddress" ] | |
| meta { | |
| domain="This is domain value." | |
| } | |
| } |
This file contains hidden or 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
| FROM python:latest | |
| RUN pip install flask | |
| COPY ./app.py /root/app.py | |
| CMD python /root/app.py |
This file contains hidden or 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
| job "web-app"{ | |
| datacenters = ["dc1"] | |
| type = "system" | |
| update { | |
| stagger = "10s" | |
| max_parallel = 1 | |
| } | |
| task "webservice" { | |
| driver = "docker" | |
| config { | |
| image = "flask-app:1.2.0" | |
| port_map { | |
| web = 5000 | |
| } | |
| } | |
| resources { | |
| network { | |
| port "web" {} | |
| } | |
| } | |
| env { | |
| DOMAIN = "${meta.domain}" | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment