Skip to content

Instantly share code, notes, and snippets.

@lgvital
Created August 14, 2019 05:08
Show Gist options
  • Save lgvital/16238659bfb43ed24620edaa1eed87b2 to your computer and use it in GitHub Desktop.
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
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