Skip to content

Instantly share code, notes, and snippets.

@damncabbage
Created April 8, 2014 05:11
Show Gist options
  • Save damncabbage/10093417 to your computer and use it in GitHub Desktop.
Save damncabbage/10093417 to your computer and use it in GitHub Desktop.
Dockerfile + docker_build.sh script, for eventual use with Jenkins CI.
#!/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Dependencies
# HACK: We're manually checking if we should be refreshing the .tar cache, as Docker
# isn't smart enough to know what our $DEPS_DIR/.git/ updates (caused by the
# fetch+reset) mean.
DEPS="babushka-deps"
DEPS_DIR="$SCRIPT_DIR/$DEPS"
DEPS_TAR="$SCRIPT_DIR/$DEPS.tar.gz"
if [ ! -d "$DEPS_DIR" ]; then
git clone git@github.com:foobar/babushka-deps "$DEPS_DIR"
fi
pushd "$DEPS_DIR"
git fetch origin
CURRENT_REF=$(git rev-parse HEAD)
ORIGIN_REF=$(git rev-parse origin/master)
if [ "$CURRENT_REF" == "$ORIGIN_REF" ] && [ -f "$DEPS_TAR" ]; then
echo "Up to date... Skipping re-archive."
else
git reset --hard origin/master
rm -f "$DEPS_TAR"
tar -cvf "$DEPS_TAR" "$DEPS_DIR"
fi
popd
# Build the image
sudo docker build .
# ... Other stuff follows.
FROM ubuntu:precise
### Lean on our existing Babushka definitions to pull in Ruby and other dependencies ###
# Babushka bootstrap
RUN apt-get update
RUN apt-get -y install curl
RUN sh -c "`curl https://babushka.me/up`"
# Babushka deps setup
RUN mkdir -p ~/.babushka/sources
ADD ./babushka-deps.tar.gz /root/.babushka/sources/foobar
# Run the Babushka deps
RUN babushka foobar:'example dep'
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment