Skip to content

Instantly share code, notes, and snippets.

View docwhat's full-sized avatar

Christian Höltje docwhat

View GitHub Profile
@docwhat
docwhat / profiling.groovy
Last active September 23, 2022 15:46
In Groovy profiling
#!/usr/bin/env groovy
// This works in Jenkinsfiles without approving any scripts.
class MyProfiler {
def timings
def dsl
MyProfiler(dsl) {
this.timings = [:]
@docwhat
docwhat / catalina.md
Last active October 23, 2019 23:03
Security issues on macOS Cataline for command line users

NOTE: The latest version is at https://docwhat.org/upgrading-to-catalina

For those upgrading to macOS Catalina!

To allow running programs, go to the “Security & Privacy” system preference, click on the “Privacy” tab, scroll down to “Developer Tools” and add (and check) all the terminal programs you use.

Example(s):

  • Terminal.app (comes with macOS).
  • iTerm.app
$ uname -a
Darwin bluewhat.local 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64 x86_64
$ k3d create --workers=2 --image=docker.io/rancher/k3s:v0.9.1
INFO[0000] Created cluster network with ID 0b01d65880241866f5e80968477ef60340b2abe408585e907e9755d1580375b1
INFO[0000] Created docker volume  k3d-k3s-default-images
INFO[0000] Creating cluster [k3s-default]
INFO[0000] Creating server using docker.io/rancher/k3s:v0.9.1...
INFO[0000] Booting 2 workers for cluster k3s-default
INFO[0001] Created worker with ID 739ef6c7ac4062bbc00159d4cb03648ba64e3b0ab06e41e0070815a709b26f83
@docwhat
docwhat / README.md
Last active October 24, 2023 17:08
Build a docker image with bash

Dockerfile as a bash script

A simple experiment.

By creating bash functions for common Dockerfile commands (e.g., RUN, COPY) you can sort of implement docker build as a bash script.

It's sort of like a cheap buildah knockoff.

It creates the image example:build.bash

@docwhat
docwhat / DockerPipelineWithCleanup.java
Last active July 22, 2019 14:07 — forked from abayer/DockerPipelineWithCleanup.java
Declarative Pipeline Docker-with-cleanup agent type
// This would be in src/main/java/whatever/DockerPipelineWithCleanup.java
package whatever;
import hudson.Extension;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.pipeline.modeldefinition.agent.AbstractDockerAgent;
import org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgent;
import org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;
@docwhat
docwhat / duquesnelight-outages.rb
Created July 11, 2019 17:25
Check for power outages from Duquesne Light in Pittsburgh.
#!/usr/bin/env ruby -w
# frozen_string_literal: true
require 'json'
require 'open-uri'
require 'date'
class Outage
attr_reader :name, :zip, :lat, :long, :number_affected, :last_updated
@docwhat
docwhat / docker-bridge-example.bash
Created April 6, 2019 21:00
Example of using docker bridge networking
#!/bin/bash
PS4='+\[\033[01;34m\](${BASH_SOURCE[0]}:${LINENO})\[\033[00m\]: ${FUNCNAME[0]:+\[\033[01;33m\]${FUNCNAME[ 0]}()\[\033[00m\]: }'
set -eu
# Tear Down previous run
{
docker container rm -f db client || true
docker network rm majidi || true
@docwhat
docwhat / Jenkinsfile
Last active December 16, 2023 13:53
Example pipeline usage of the Jenkins Mask Passwords plugin
// Requires https://plugins.jenkins.io/mask-passwords to run
/**
* Runs code with secret environment variables and hides the values.
*
* @param varAndPasswordList - A list of Maps with a 'var' and 'password' key. Example: `[[var: 'TOKEN', password: 'sekret']]`
* @param Closure - The code to run in
* @return {void}
*/
def withSecretEnv(List<Map> varAndPasswordList, Closure closure) {
@docwhat
docwhat / example.md
Last active August 14, 2018 17:35
docker-envfile-example

The format of the env-file is explain at https://docs.docker.com/compose/env-file/.

# I'm using bash, but it applies with sh and zsh as well.
$ echo $BASH_VERSION
4.4.23(1)-release
# Create a simple env-file for testing.  We're using = and ! to
# push at some corner cases.
$ echo 'THISISAVARIABLE=This is the value that even has an = sign!' > /tmp/concoction.env
$ cat /tmp/concoction.env
@docwhat
docwhat / Dockerfile
Created May 18, 2018 18:42
Multi-stage maven dockerfile with caching
# Requires docker 17.06 to build
# ----
# Install Maven
FROM openjdk:8-jdk-alpine AS maven
RUN apk add --no-cache curl tar bash
ARG MAVEN_VERSION=3.3.9
ARG USER_HOME_DIR="/root"
RUN mkdir -p /usr/share/maven && \
curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar -xzC /usr/share/maven --strip-components=1 && \