Skip to content

Instantly share code, notes, and snippets.

View eugenestarchenko's full-sized avatar
:octocat:

Eugene S eugenestarchenko

:octocat:
View GitHub Profile
@eugenestarchenko
eugenestarchenko / Dockerfile
Created March 31, 2017 11:20 — forked from yefim/Dockerrun.aws.json
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
# Example Dockerfile
FROM hello-world
@eugenestarchenko
eugenestarchenko / docker_registry_cleaner.py
Created April 6, 2017 11:44 — forked from sportebois/docker_registry_cleaner.py
Clean untagged images from AWS ECR registry
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import argparse
import boto3
parser = argparse.ArgumentParser(description='Cleanup Docker images form ECR.')
parser.add_argument('--repository-name', metavar='repo', dest='repository_name', required=True, help='Repository name')
parser.add_argument('--registry-id', metavar='registry', dest='registry_id', required=False, help='Registry ID.If you do not specify a registry, the default registry is assumed.')
parser.add_argument('--delete', dest='delete', required=False, default=False, action='store_true', help='If set to true, delete the untagged images. Otherwise (default), only list them')
@eugenestarchenko
eugenestarchenko / wipeout-aws-ecr-images.sh
Created April 6, 2017 11:47 — forked from rpherrera/wipeout-aws-ecr-images.sh
Wipeout all Docker Images found into an AWS account from ECR private registry, parsing results with jq.
#!/bin/bash -ex
# Warning: use with caution! Once ran, this script is going to wipeout all
# images that you own into your AWS ECR.
aws ecr describe-repositories | jq '.repositories[].repositoryName' | sed s/\"//g | while read repository_name; do
batch_delete_string=''
aws ecr list-images --repository-name "${repository_name}" | \
jq '.imageIds[].imageTag' | while read image_tag; do
batch_delete_string="imageTag=${image_tag} "
@eugenestarchenko
eugenestarchenko / migrate_ecr_region.sh
Created April 7, 2017 11:36 — forked from y-takagi/migrate_ecr_region.sh
ECRのリージョン移行
#!/bin/bash
#
# 前準備として、移行先に各イメージのレポジトリを作成しておく必要あり。
# $from、$to、$aws_account_id、$images は適宜変更する。
#
set -e
from="us-east-1"
to="ap-northeast-1"
aws_account_id=""
@eugenestarchenko
eugenestarchenko / push_docker_image.sh
Created April 7, 2017 11:38 — forked from kuntao/push_docker_image.sh
shell script for build Dockerfile and push the image to ECR
#!/bin/bash
REPOSITORY=[[[[[ecr_registrory_name]]]]]
IMAGE=$REPOSITORY:latest
AWS_REGION=[[[[[your_region]]]]]
# docker login
aws ecr get-login --region $AWS_REGION
# docker build
@eugenestarchenko
eugenestarchenko / aws-ecs-cli-login.sh
Created April 7, 2017 11:40 — forked from itskingori/aws-ecs-cli-login.sh
Authenticate into AWS ECR. Useful in a CI environment (to push images) ... and so on. If you're unhappy evaluating unvalidated commands ... this adds a regex that checks the output from get-login.
# See https://forums.aws.amazon.com/thread.jspa?threadID=222215
aws_login=$(aws ecr get-login --region us-east-1);
if echo "$aws_login" | grep -q -E '^docker login -u AWS -p \S{1092} -e none https://[0-9]{12}.dkr.ecr.\S+.amazonaws.com$'; then $aws_login; fi
@eugenestarchenko
eugenestarchenko / aws-codebuild-cross-account-image-push.yml
Created April 7, 2017 11:53 — forked from tvalletta/aws-codebuild-cross-account-image-push.yml
AWS CodeBuild buildspec.yml example for building a docker image and pushing it to a AWS ECS docker repo in another AWS account
version: 0.1
# REQUIRED ENVIRONMENT VARIABLES
# AWS_KEY - AWS Access Key ID
# AWS_SEC - AWS Secret Access Key
# AWS_REG - AWS Default Region (e.g. us-west-2)
# AWS_OUT - AWS Output Format (e.g. json)
# AWS_PROF - AWS Profile name (e.g. central-account)
# IMAGE_REPO_NAME - Name of the image repo (e.g. my-app)
# IMAGE_TAG - Tag for the image (e.g. latest)
@eugenestarchenko
eugenestarchenko / ecs-tasks.sh
Created June 14, 2017 12:53 — forked from coryodaniel/ecs-tasks.sh
ECS Agent what are your intensions with my tasks?
yum install jq
curl 127.0.0.1:51678/v1/tasks | jq '[.Tasks[] | {task: "\(.Family):\(.Version)",status: "\(.KnownStatus) -> \(.DesiredStatus)", dockerId: .Containers[0] | .DockerId}] | sort_by(.task,.dockerId)'
@eugenestarchenko
eugenestarchenko / deregister.sh
Created October 6, 2017 11:17 — forked from bpholt/deregister.sh
Stop tasks on ECS Container Instance and Deregister it from ECS Cluster
#!/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
@eugenestarchenko
eugenestarchenko / deregister.sh
Created October 6, 2017 11:17 — forked from bpholt/deregister.sh
Stop tasks on ECS Container Instance and Deregister it from ECS Cluster
#!/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