Skip to content

Instantly share code, notes, and snippets.

View themegabyte's full-sized avatar

Shayan themegabyte

View GitHub Profile
@themegabyte
themegabyte / run.tpl
Created April 25, 2024 04:55 — forked from efrecon/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name {{printf "%q" .Name}} \
{{- with .HostConfig}}
{{- if .Privileged}}
--privileged \
{{- end}}
{{- if .AutoRemove}}
--rm \
{{- end}}
{{- if .Runtime}}
#!/usr/local/bin/bash
# pkg install bash
# add to shellcmd as "/root/push_ip_metrics.sh &" via Services/shellcmd
pushgatewayip="192.168.1.2:9091"
network="192.168.1.0/24"
interface="bce1"
interval="1"
rate -i "${interface}" -r "${interval}" -e -n -Ab -a 255 -c "${network}" -d | while read -r line; do
@themegabyte
themegabyte / node_exporter.sh
Created February 26, 2024 20:33 — forked from galexrt/node_exporter.sh
Simple Prometheus node_exporter install script (Updated for 1.0.1)
#!/bin/bash
version="${VERSION:-1.0.1}"
arch="${ARCH:-linux-amd64}"
bin_dir="${BIN_DIR:-/usr/local/bin}"
wget "https://github.com/prometheus/node_exporter/releases/download/v$version/node_exporter-$version.$arch.tar.gz" \
-O /tmp/node_exporter.tar.gz
mkdir -p /tmp/node_exporter
@themegabyte
themegabyte / replace-apt-mirror.md
Created October 18, 2023 15:03 — forked from yusufhm/replace-apt-mirror.md
replace default apt with au mirror using Vim or sed
@themegabyte
themegabyte / 01-multistage-build.sh
Created July 11, 2023 06:33 — forked from evadne/01-multistage-build.sh
Build & Cache multi-stage Docker images (with Build Specification for AWS CodeBuild)
# the general idea
ImageTag="git"
FilePath="/Dockerfile"
RepoURI="123456789012.dkr.ecr.eu-west-1.amazonaws.com/repo"
Stages=$(cat $FilePath | grep -oP '^FROM .+ (AS|as) \K(.+)$')
CacheArgs=$(for Stage in $Stages; do echo "--cache-from $RepoURI:cache-$Stage"; done | paste -sd ' ')
BuildArgs="--file $FilePath $CacheArgs"
for Stage in $Stages; do docker pull $RepoURI:cache-$Stage || true; done
for Stage in $Stages; do docker build $BuildArgs --tag $RepoURI:cache-$Stage --target $Stage . || break; done
docker build $BuildArgs --tag $RepoURI:$ImageTag .