Packer
-
Packer is used to build image from a base image, perform provisions and store (commit) the final image.
-
We use provisioners and Packer templates to do the actual work to create the final image.
-
We use Ansible for provisioning.
| # This is just a cheat sheet: | |
| # On production | |
| sudo -u postgres pg_dump database | gzip -9 > database.sql.gz | |
| # On local | |
| scp -C production:~/database.sql.gz | |
| dropdb database && createdb database | |
| gunzip < database.sql.gz | psql database |
| #!/bin/bash | |
| cluster=default | |
| container_instance= # container instance guid | |
| tasks=$(aws --region us-west-2 ecs list-tasks --container-instance $container_instance --cluster $cluster | jq -r '.taskArns | map(.[40:]) | reduce .[] as $item (""; . + $item + " ")') | |
| for task in $tasks; do | |
| aws --region us-west-2 ecs stop-task --task $task --cluster $cluster | |
| done | |
| aws --region us-west-2 ecs deregister-container-instance --cluster $cluster --container-instance $container_instance |
| #!/bin/bash | |
| # get all running docker container names | |
| containers=$(sudo docker ps | awk '{if(NR>1) print $NF}') | |
| host=$(hostname) | |
| # loop through all containers | |
| for container in $containers | |
| do | |
| echo "Container: $container" |
Packer
Packer is used to build image from a base image, perform provisions and store (commit) the final image.
We use provisioners and Packer templates to do the actual work to create the final image.
We use Ansible for provisioning.
| #Original Author https://raw.githubusercontent.com/kgoedecke/python-ecs-example/master/python_ecs_example/deployment.py | |
| import boto3 | |
| import pprint | |
| import os | |
| # Credentials & Region | |
| access_key = os.environ["AWS_ACCESS_KEY_ID"] | |
| secret_key = os.environ["AWS_SECRET_ACCESS_KEY"] | |
| region = "us-east-1" |
| #!/usr/bin/env python3 | |
| # vim: ft=python ts=4 sw=4 expandtab | |
| # | |
| # Copyright (c) 2013 Reed Kraft-Murphy <[email protected]> | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| # of this software and associated documentation files (the "Software"), to deal | |
| # in the Software without restriction, including without limitation the rights | |
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| # copies of the Software, and to permit persons to whom the Software is |
| #!/usr/bin/env python | |
| import boto3 | |
| import argparse | |
| def lookup_by_id(sgid): | |
| sg = ec2.get_all_security_groups(group_ids=sgid) | |
| return sg[0].name | |
| FILES=*.rst | |
| for f in $FILES | |
| do | |
| filename="${f%.*}" | |
| echo "Converting $f to $filename.md" | |
| `pandoc $f -f rst -t markdown -o $filename.md` | |
| done |
| goaccess -f haproxy.log --log-format='%^ %^ %^:%^:%^ %^ %^[%^]: %h:%^ [%d:%t.%^] %^ %^ %^/%^/%^/%^/%L %s %b %^ %^ %^ %^/%^/%^/%^/%^ %^/%^ "%r"' --date-format='%d/%b/%Y' --time-format='%H:%M:%S' -q |