Created
August 14, 2019 05:08
-
-
Save lgvital/16238659bfb43ed24620edaa1eed87b2 to your computer and use it in GitHub Desktop.
1. Set $ECS_CLUSTER variable. 2. Add this to wherever production.yml is located. 3. python deploy.py
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
import yaml | |
import subprocess | |
def main(): | |
subprocess.run(['docker-compose', '-f', 'production.yml', 'build']) | |
with open("production.yml", 'r') as stream: | |
try: | |
prod_yaml = yaml.safe_load(stream) | |
for service in prod_yaml.get('services').values(): | |
image = service['image'] | |
print(subprocess.run(['docker', 'push', image])) | |
except yaml.YAMLError as exc: | |
print(exc) | |
subprocess.run(['ecs-cli', 'compose', '--file', 'production.yml', 'service', 'up', '--cluster', '$ECS_CLUSTER']) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment