Skip to content

Instantly share code, notes, and snippets.

View markwylde's full-sized avatar

Mark Wylde markwylde

View GitHub Profile
@markwylde
markwylde / README.md
Created November 21, 2019 05:51
Create a Weave Docker

DOCKER

sudo apt-get update
sudo apt-get -y install \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg2 \
     software-properties-common
@markwylde
markwylde / index.js
Created November 19, 2019 03:54
Create a simple https server with letsencrypt
const https = require('https');
const http = require('http');
const fs = require('fs');
const options = {
key: fs.readFileSync('/etc/letsencrypt/live/example.com/privkey.pem'),
cert: fs.readFileSync('/etc/letsencrypt/live/example.com/cert.pem'),
ca: fs.readFileSync('/etc/letsencrypt/live/example.com/fullchain.pem')
};
@markwylde
markwylde / index.js
Created November 12, 2019 11:09
Promise replacement with Righto
async function syncCollectionOnServer (collectionName, server) {
const schema = await fetch({
url: 'http://manager.example.test/products'
})
const collection = await fetch({
method: 'post',
data: schema,
url: `${server}/${collectionName}`
})
@markwylde
markwylde / httpRequest.js
Created November 11, 2019 05:26
Make an http request natively in nodejs
const http = require('http')
const https = require('https')
function httpRequest (options, callback) {
const uri = new URL(options.url)
const httpOrHttps = uri.protocol === 'https:' ? https : http
const opts = {
headers: options.headers || {},
method: 'GET',
@markwylde
markwylde / README.md
Last active October 25, 2019 23:34
Create a container deployment service

Deploy King

Create an new SSH key

We need to create a new SSH key that we will give GitHub for the CI jobs.

user@computer.local api % ssh-keygen       
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/user/.ssh/id_rsa): /Users/user/.ssh/github-do-marriage_rsa
Enter passphrase (empty for no passphrase): 
@markwylde
markwylde / index.js
Created September 19, 2019 10:05
Bigger stack traces on promises
/*
Magic to get bigger stack traces
*/
const asyncHooks = require('async_hooks')
const stackTraces = new Map()
function init (asyncId) {
let capturedStackTrace = {}
Error.captureStackTrace(capturedStackTrace)
stackTraces.set(asyncId, capturedStackTrace.stack)
@markwylde
markwylde / auth-config.yml
Created September 14, 2019 09:57
Auth Stack
version: "3.7"
services:
auth-ui:
image: msplat/auth-ui:local
build: ./ui/
ports:
- 9180:80
volumes:
- ./ui:/app
@markwylde
markwylde / keybase.md
Last active September 12, 2019 11:21

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@markwylde
markwylde / create-swarm-cluster.sh
Last active December 10, 2021 13:06
Create a Docker Swarm cluster with a configuration amount of workers on Digital Ocean or using Virtual Box
# How many swarm workers do you want?
WORKER_COUNT="${WORKER_COUNT:-5}"
# What would you like to prefix all your VM's with?
CLUSTER_NAME="${CLUSTER_NAME:-mycluster}"
# Set this to true to use virtualbox instead of digitalocean driver
LOCAL_VIRTUALBOX="${LOCAL_VIRTUALBOX:-true}"
# Virtualbox Configuration

Example

1. Docker swarm

Make docker a one node swarm cluster.

docker swarm init

2. Create network