Skip to content

Instantly share code, notes, and snippets.

View briceburg's full-sized avatar

Brice Burgess briceburg

  • toil over toil
  • albuquerque, nm
View GitHub Profile
@briceburg
briceburg / mk-jwt-token
Last active December 9, 2023 03:47
mk-jwt-token -- bash shell script for generating JWT tokens. requires `openssl` and `base64` which you have.
#!/usr/bin/env bash
#
# usage: JWT_SECRET="silly" mk-jwt-token
# @WARN: modify the payload and header to your needs.
#
main(){
set -eo pipefail
[ -n "$JWT_SECRET" ] || die "JWT_SECRET environment variable is not set."
@briceburg
briceburg / build-docker-images
Created October 18, 2023 01:37
bin/build - Docker Image building shell wrapper
#!/usr/bin/env bash
set -eo pipefail
project_root="$(cd "$(dirname "$0")/.." ; pwd -P)"
default_env="prod"
default_src="Dockerfile"
default_tag="build:latest"
(
echo "Build Dir: ${BUILD_DIR:=$project_root}" >&2
@briceburg
briceburg / Dockerfile.fails
Created March 30, 2016 22:17
docker - example adding www-data user to alpine images
FROM nginx:alpine
# stock verison from php:alpine image
# ensure www-data user exists
RUN set -x \
&& addgroup -g 82 -S www-data \
&& adduser -u 82 -D -S -G www-data www-data
# 82 is the standard uid/gid for "www-data" in Alpine
# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2
@briceburg
briceburg / print-jenkins-secret-file-contents.groovy
Created June 8, 2021 16:08
Print content of secret files from the Jenkins Credentials Store
import com.cloudbees.plugins.credentials.*;
import com.cloudbees.plugins.credentials.domains.Domain;
import org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl;
//
// modify fileName to match the filename of the secret(s) you want to print.
// (ID would probably be more helpful... yay stack overflow copy pasta)
// alternatively comment out the filter [line 15] to dump all secret files.
//
def fileName = "secrets.env"
@briceburg
briceburg / Dockerfile
Last active April 12, 2023 20:39
TCP Proxy to a Postgres Database - HAProxy Configuration Example
FROM haproxy:2.7-alpine
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
ARG SOURCE_COMMIT=""
ENV DD_SERVICE="haproxy" DD_ENV="local" DD_VERSION="$SOURCE_COMMIT"
@briceburg
briceburg / main.tf
Last active March 21, 2023 18:45
Terraform ECR authentication
resource "aws_ecr_repository" "repo" {
name = "foo"
}
data "aws_ecr_authorization_token" "repo" {}
#
# providers.tf
#
@briceburg
briceburg / README.md
Last active March 7, 2023 17:43
Aligning RAILS_ENV, DD_ENV, Amplify Stage, Namespace Stage in AWS Deployments

Questions

  • should RAILS_ENV == DD_ENV
  • should DD_ENV == NAMESPACE_STAGE

how do we make these decisions?

current environment

  • lower level deployed heroku apps use 'staging' as RAILS_ENV.
@briceburg
briceburg / create-postgresql-databases.sh
Last active February 14, 2023 00:41
official PostgresSQL docker images - create multiple databases
#!/bin/bash
set -e
if [ -n "$POSTGRES_DATABASES" ]; then
echo "POSTGRES_DATABASES provided. Creating multiple databases..." >&2
IFS=', '; for db in $POSTGRES_DATABASES; do
echo "Creating '$db'" >&2
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-ESQL
CREATE USER "$db";
CREATE DATABASE "$db";
@briceburg
briceburg / reduce_replacements.py
Last active February 4, 2023 07:17
Python multiple replacements using reduce
#!/usr/bin/env python3
import sys
import functools
for line in map(str.rstrip, sys.stdin):
repls = ('prod', 'production'), ('sdlc', 'staging'), ('sandbox', 'development')
print("terraform state mv %s %s" % (line, functools.reduce(lambda a, kv: a.replace(*kv), repls, line)))
@briceburg
briceburg / keybase.md
Last active August 9, 2022 14:54
keybase.md

Keybase proof

I hereby claim:

  • I am briceburg on github.
  • I am briceburg (https://keybase.io/briceburg) on keybase.
  • I have a public key ASAmp_PrGxxKN6LJvOQofrkFL1wJNrAaWxmuvczD3phMqQo

To claim this, I am signing this object: