Skip to content

Instantly share code, notes, and snippets.

@ederparaiso
ederparaiso / git-cleanup-old-branches.sh
Last active June 11, 2018 17:19
Removes all branches that don't exist in remote repo anymore
#!/bin/bash
cd $1
git checkout master
git fetch --prune
OLD_BRANCHES=$(git branch -v | grep gone | cut -d " " -f3)
for branch in ${OLD_BRANCHES}; do
git branch -D ${branch}
done
@ederparaiso
ederparaiso / Docker-centos7-systemd-sshd.md
Last active February 24, 2024 09:00
docker-centos7-systemd-sshd

Docker centOS 7 based with systemd enabled and sshd installed.

Build image

docker build --rm -t c7-systemd-sshd .

Run

docker run --rm --privileged=true -p 22:22 -v /sys/fs/cgroup:/sys/fs/cgroup:ro c7-systemd-sshd

Alternatively you can use docker compose

@ederparaiso
ederparaiso / provision-docker.yml
Created November 27, 2018 21:07
provision docker with ansible
- hosts: host-list
sudo: yes
tasks:
- name: "Installing Docker Prerequisite packages"
yum:
name: "{{ item }}"
state: latest
with_items:
- yum-utils
- device-mapper-persistent-data
@ederparaiso
ederparaiso / provision-nginx.yml
Created November 27, 2018 21:09
provision nginx with ansible
- hosts: host-list
sudo: yes
tasks:
- name: "Add epel-release repo"
yum:
name: epel-release
state: present
- name: "Install nginx"
yum:
name: nginx
@ederparaiso
ederparaiso / provision-nexus.yml
Created November 27, 2018 21:10
provision nexus repository manager with ansible
- hosts: host-list
sudo: yes
tasks:
- name: "Install pip"
easy_install:
name: pip
- name: "Install docker-py"
pip:
name: docker-py
- name: "Create nexus-data dir and make it writable by the Nexus process, which runs as UID 200"
server {
listen *:80;
server_name my.nexus.url;
# and redirect to the non-www host (declared below)
return 301 https://my.nexus.url$request_uri;
}
server {
listen 443 ssl;
server_name my.nexus.url;
@ederparaiso
ederparaiso / azurecr-purge.sh
Created October 20, 2019 21:09
Purge container images in Azure Container Registry
#!/bin/bash
# WARNING! This script deletes data!
# Purge old images retaining configured amount of tags. Tag latest will be always preserved.
REGISTRY=your_registry
REPOSITORY=your_repository
HISTORY_SIZE=amount_of_tags_to_be_remain
az acr repository show-tags -n $REGISTRY --repository $REPOSITORY --orderby time_desc --query "[?@ != 'latest'] | [$HISTORY_SIZE:]" -o tsv \
@ederparaiso
ederparaiso / azurecr-purge-orphaned.sh
Created October 20, 2019 23:01
Purge untagged container images in Azure Container Registry
#!/bin/bash
# WARNING! This script deletes data!
# Purge untagged (orphaned) images
REGISTRY=your_registry
REPOSITORY=your_repository
az acr repository show-manifests --name $REGISTRY --repository $REPOSITORY --query "[?tags[0]==null].digest" -o tsv \
| xargs --replace=digest --verbose az acr repository delete -n $REGISTRY --image $REPOSITORY@digest --yes