Skip to content

Instantly share code, notes, and snippets.

View clcollins's full-sized avatar

Christopher Collins clcollins

View GitHub Profile
@clcollins
clcollins / WorkingWithForks.md
Created July 30, 2018 16:47
Git Cheet Sheet

Working With Forks/Upstream

Get Upstream Tags

Update Git config

Add this to the [upstream] section in .git/config

fetch = +refs/tags/*:refs/tags/*

@clcollins
clcollins / cleanup_docker.sh
Created June 7, 2018 18:31 — forked from ralphtheninja/cleanup_docker.sh
Cleanup and reset docker on Jenkins workers / slaves
#!/bin/bash
# This script should be located on each Jenkins slave, and the jenkins user should have permission to run it with sudo
# Attempts to cleanly stop and remove all containers, volumes and images.
docker ps -q | xargs --no-run-if-empty docker stop
docker ps -q -a | xargs --no-run-if-empty docker rm --force --volumes
docker volume ls -q | xargs --no-run-if-empty docker volume rm
docker images -a -q | xargs --no-run-if-empty docker rmi -f
# Stops the docker service, unmounts all docker-related mounts, removes the entire docker directory, and starts docker again.

Example Ruby On Rails development workflow with containers

This is an example of a workflow we've developed to develop Ruby on Rails applications in Docker containers, to assure the local development occurs in the same environment as the production workload. It also has the side benefit of making local development easier: every project can be built with whatever dependencies or libraries are desired, without having to try to install them on the developers' local machines. In addition, local tools and direct code manipulation are still possible, making development feel entirely native to the local machine.

This general workflow works for other languages just as easily. See the "What about other languages?" section, below.

Assumptions:

  1. You have a database container that will initialize itself on startup, setup DB & user/password
@clcollins
clcollins / docker-compose.yml
Created September 12, 2017 22:39
Docker Compose-based, single-server deploy of CHN Server
version: '2'
services:
mongodb:
build:
dockerfile: ./Dockerfile-centos
context: https://github.com/CommunityHoneyNetwork/mongodb.git
image: mongodb:centos
ports:
- "127.0.0.1:27017:27017"
volumes:
@clcollins
clcollins / Dockerfile
Last active May 15, 2019 15:17
mkdocs in a Docker container
FROM ubuntu:17.10
MAINTAINER Chris Collins <[email protected]>
ENV PKGS python python-pip nginx runit
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y $PKGS
RUN pip install mkdocs
ADD default /etc/nginx/sites-enabled/default
@clcollins
clcollins / chnserver_deploy.sh
Last active May 15, 2019 15:16
CHN-Server Docker Compose file
#!/bin/bash
set -o errexit
set -o nounset
main () {
local mongo_repo="https://github.com/CommunityHoneyNetwork/mongodb.git"
local mongo_commit="c95ab34ba961b4e29b9973a7eec2d0133f15be5c"
local redis_repo="https://github.com/CommunityHoneyNetwork/redis.git"
local redis_commit="b7ad930a8d7a0296fb2fadf955e2a58c3aee73e4"
@clcollins
clcollins / ansible_error.txt
Created May 22, 2017 20:22
Error & Inventory file from OpenShift Origin Ansible install
fatal: [10.0.11.227]: FAILED! => {"changed": false, "cmd": ["/usr/local/bin/oc", "create", "-n", "openshift", "-f", "/etc/origin/examples/image-streams/image-streams-centos7.json"], "delta": "0:00:00.648866", "end": "2017-05-22 19:52:08.699647", "failed": true, "failed_when_result": true, "rc": 1, "start": "2017-05-22 19:52:08.050781", "stderr": "Unable to connect to the server: dial tcp: lookup <HOSTNAME OF ELB FOR MASTERS> on 10.0.0.2:53: no such host", "stderr_lines": ["Unable to connect to the server: dial tcp: lookup <HOSTNAME OF ELB FOR MASTERS> on 10.0.0.2:53: no such host"], "stdout": "", "stdout_lines": []}
@clcollins
clcollins / enable_namespaces_el7.sh
Last active April 25, 2017 20:41
Enable User Namespaces for Docker on EL7-based Systems
#!/bin/bash
# Super basic script outlining the steps to enable namespace support for Docker on
# el7-base systems (CentOS7, RHEL7, etc).
set -e
echo "Enabling user_namespace kernel option..."
grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
@clcollins
clcollins / git-prompt
Created April 18, 2017 16:35
Git Prompt for bash
# Found on Reddit - cannot now remember where
# Modified by Chris Collins to suite his tastes
git rev-parse 2> /dev/null && git status --porcelain -b | awk '
/^## / {
branch = $0;
sub(/^## /, "", branch);
sub(/\.\.\..*/, "", branch);
if ($0 ~ /ahead /) {

Docker Build Pipeline with Remote Asset Compilation

Problem

To compile code into assets/artifacts and build a Docker image with the resulting code only, and no compilers/devel packages/libraries, you have a workflow like so: