Public | Automated Build

Last pushed: 5 days ago
Short Description
Lightweight Read-Through GitHub Mirror Cache
Full Description

Lightweight read-through GitHub mirror cache

The content of this container image is intended to be run on a Kubernetes cluster, in order to make all our upstream GitHub-hosted repositories available for cloning via a local git server. This "mirror cache" will help ensure that we aren't cloning entire repos (TJS = ~2GB) every time we go to build a deployment artifact.

We're using a small python library to do the initialization of the repos at run-time.

Usage

Environment Variables

  • GITHUB_ORG: the GitHub organization we'll be mirroring repos for
  • GITHUB_USER: the user we'll authenticate to GitHub with
  • GITHUB_TOKEN: the OAuth API token that authenticates the GITHUB_USER

Local Testing

# Build the image
docker build -t tapjoy/github-mirror .

# Setup your GitHub details and creds
export GITHUB_ORG=tapjoy GITHUB_USER=username GITHUB_TOKEN=$YOUR_GITHUB_PERSONAL_ACCESS_TOKEN

# Create a container from the image and label it with your chosen pod name
kubectl run --image=tapjoy/github-mirror --env GITHUB_ORG=$GITHUB_ORG --env GITHUB_USER=$GITHUB_USER --env GITHUB_TOKEN=$GITHUB_TOKEN -l component=mirrortest mirrortest

### (You might have to wait a few seconds for the pod to finish the github-mirror container's entrypoint setup)

# Create a temporary pod with environment variable that points to the IP of the mirror pod created above, and jump into it for testing
kubectl run --rm -it --image=ruby --env GITHUB_MIRROR=$(kubectl get pod -l component=mirrortest -o jsonpath="{.items[0].status.podIP}") temptest -- bash

## Once you're in the temporary pod, try cloning a repo from the mirroring pod
git clone git://$GITHUB_MIRROR/github-mirror.git
#Cloning into 'github-mirror'...
#remote: Counting objects: 7, done.
#remote: Compressing objects: 100% (6/6), done.
#remote: Total 7 (delta 0), reused 0 (delta 0)
#Receiving objects: 100% (7/7), done.
#Checking connectivity... done.
ls -l github-mirror/
#total 16
#-rw-r--r-- 1 root root  225 May 19 02:42 Dockerfile
#-rw-r--r-- 1 root root   49 May 19 02:42 README.md
#-rwxr-xr-x 1 root root  599 May 19 02:42 entrypoint.sh
#drwxr-xr-x 2 root root 4096 May 19 02:42 scripts
Docker Pull Command
Owner
tapjoy
Source Repository

Comments (0)