Skip to content

Instantly share code, notes, and snippets.

@beldpro-ci
beldpro-ci / Dockerfile
Created May 16, 2017 14:03
Dockerfile that install OpenJDK8 to Debian
FROM debian:jessie
RUN set -ex && \
echo 'deb http://deb.debian.org/debian jessie-backports main' \
> /etc/apt/sources.list.d/jessie-backports.list && \
apt update -y && \
apt install -t \
jessie-backports \
openjdk-8-jre-headless \
@beldpro-ci
beldpro-ci / events.go
Created May 13, 2017 17:24
Sample table that uses Roach as the Db connection pooler
// tables package holds the methods for manipulating specific
// postgres tables.
package tables
import (
"time"
"github.com/davecgh/go-spew/spew"
"github.com/pkg/errors"
@beldpro-ci
beldpro-ci / roach.go
Created May 13, 2017 14:23
Postgres connection handling with Golang
// roach wraps `lib/pq` providing the basic methods for
// creating an entrypoint for our database.
package roach
import (
"database/sql"
"fmt"
"github.com/davecgh/go-spew/spew"
"github.com/pkg/errors"
Bearer to Basic
http -v :80/bearer-to-basic Authorization:'Bearer token'
GET /bearer-to-basic HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Authorization: Bearer token
Connection: keep-alive
Host: localhost:80
User-Agent: HTTPie/0.9.9
@beldpro-ci
beldpro-ci / auth-dump.lua
Created May 9, 2017 00:51
Lua module to dump all request headers to the http client
-- Outputs the contents of the headers
-- in a plain text format.
-- Headers:
-- key=value
return function ()
-- 'ngx.say' emits content to the HTTP client of that
-- request.
ngx.say("Headers:")
-- 'req.get_headers' gives us a lua table that
@beldpro-ci
beldpro-ci / basic-to-git-bearer.lua
Created May 9, 2017 00:39
Rewrite a Basic authorization to Bearer authorization
local log = ngx.log
local ERR = ngx.ERR
-- Requiring the basic string manipulationn utilities
-- from a file that lives at '/etc/nginx/*.lua' as
-- indicated in the 'nginx.conf' file.
require("utils")
-- Rewrites an `Authorization: Basic b64(<token>:"")` header
@beldpro-ci
beldpro-ci / nginx.conf
Created May 9, 2017 00:23
Configuration for a NGINX configuration that loads some lua modules
worker_processes 1;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
@beldpro-ci
beldpro-ci / Makefile
Created May 9, 2017 00:05
makefile to run openresty container w/ header replacement
CONTAINER_NAME := nginx-lua-tests
# RUN is responsible for running our container.
# First it removes any prvevious containers that
# were set up during testing, ignoring errors.
# Then, it runs a container using
# openresty/opernresty:alpine-fat as the base image.
# It binds a volume with our nginx configuration and
# lua volumes so that we don't need to create a custom
# image and keep restarting the container.
@beldpro-ci
beldpro-ci / ami.json
Created May 3, 2017 20:40
Docker-enabled AMI
{
"variables": {
"aws_access_key": "<access_key>",
"aws_secret_key": "<secret_key>"
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
@beldpro-ci
beldpro-ci / deploy.sh
Created May 2, 2017 14:22
consul stack deploy - terminal
docker stack deploy \
--compose-file ./docker-compose.yml \
mystack
docker service ls
NAME MODE REPLICAS IMAGE
mystack_consul replicated 3/3 consul:0.7.2