Skip to content

Instantly share code, notes, and snippets.

FROM ruby:2.4.2-alpine AS base
RUN apk add --update \
postgresql-dev git freetds-dev sqlite-dev tzdata
FROM base AS dependencies
WORKDIR /app
RUN apk add --update build-base
COPY Gemfile Gemfile.lock ./
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["src/MyApp/MyApp.csproj", "src/MyApp/"]
COPY ["src/MyApp/NuGet.Config", "src/MyApp/"]
export LC_ALL=C
FILE_NAME=$(date +%s).sar
for file in /var/log/sysstat/sa[0-9]*; do sar -A -f "$file" >> ~/$FILE_NAME; done
stages:
- build
- deploy
docker-build:
image: docker:latest
stage: build
services:
- docker:dind
before_script:
@alwalker
alwalker / az_app_svc_manual_wh.sh
Created April 15, 2021 20:48
Script for hitting Azure App Services web hook for "continuous deployment" with containers.
if [[ "$#" -ne 6 ]]; then
echo -e "Incorrect number of arguments. You need to provide:\nImage Repository\nImage Tag\nRegistry FQDN\nWebhook URL\nWebhook User\nWebhook Password"
exit 1
fi
IMAGE_REPOSITORY=$1
IMAGE_TAG=$2
REGISTRY_FQDN=$3
HOOK_URL=$4
HOOK_USER=$5
@alwalker
alwalker / ado_merger_release_env_vars.sh
Created February 24, 2021 16:40
A script to merge the variables for two environments in an Azure DevOps release pipeline.
#!/usr/bin/env bash
set -e
#Check Arguments
if [ $# -lt 3 ]; then
echo "Insuffecient arguments supplied. Shoudl be: ado_copy_relase_vars.sh src dest RELEASE_ID"
exit 1
fi
SOURCE_ENV=$1
DEST_ENV=$2
@alwalker
alwalker / gitfinder.sh
Created January 11, 2021 14:51
Search current directory for git repos and generate script to recreate them.
set -e
echo "set -e" > gitbuilder.sh
dirs=()
readarray -d '' dirs < <(find . -name .git -type d -prune)
for dir in ${dirs[@]}; do
cleandir=$(echo $dir | sed 's/\.git//')
remote=$(git --git-dir=$dir remote -v | grep fetch | sed -r 's/origin\s+//' | sed -r 's/\s+\(fetch\)//')
@alwalker
alwalker / add_current_ip_to_fw.sh
Created October 2, 2020 15:23
One liner for adding your current IP to a Azure SQL Server firewall. Used in ADO.
MYIP=$(curl -s http://ipinfo.io/json | jq -r '.ip') && \
MATCH="^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" && \
if [[ $MYIP =~ $MATCH ]]; then \
echo "Adding $MYIP to $(SERVER_NAME) firewall"; \
az sql server firewall-rule create -g $(RESOURCE_GROUP) -s $(SERVER_NAME) -n ALLOW_ADO --start-ip-address $MYIP --end-ip-address $MYIP; \
else \
echo "$MYIP is not a valid IP address."; \
exit 1; \
fi
@alwalker
alwalker / get_latest_blob.sh
Created February 19, 2019 14:57
Get Latest BLOB
NEWEST_BLOB=$(az storage blob list \
--account-key $STORAGE_KEY \
--account-name $STORAGE_ACCOUNT \
-c $CONTAINER \
--prefix $PREFIX \
--query "[*].{name: name, date: properties.lastModified } | sort_by([*], &date) | [-1].name")
NEWEST_BLOB=$(echo $NEWEST_BLOB | tr -d \")
@alwalker
alwalker / certbot_cloudflare.sh
Created August 7, 2018 13:25
Flags needed to make dns challenge for letsencrypt work with cloudflare
sudo certbot renew --preferred-challenges dns --dns-cloudflare --dns-cloudflare-credentials ~/.secrets/cloudflare.ini --dry-run