Skip to content

Commit 4c58b5d

Browse files
committed
Added docker build and version file
2 parents 7122de2 + f26d62f commit 4c58b5d

File tree

5 files changed

+65
-2
lines changed

5 files changed

+65
-2
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Dockerfile
2+
README.md
3+
version

Dockerfile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM ruby:2.0.0-p645-slim
2+
MAINTAINER Lewis Marshall <[email protected]>
3+
4+
# Update and install all of the required packages.
5+
RUN apt-get update && apt-get install -y \
6+
wget \
7+
tar
8+
9+
# TODO: could make these just mount points (to stay compatible with platform)
10+
# Download the fleetctl binary:
11+
RUN FLEET_URL=https://github.com/coreos/fleet/releases/download/v0.10.2/fleet-v0.10.2-linux-amd64.tar.gz && \
12+
export FLEET_TAR=$(basename ${FLEET_URL}) && \
13+
wget -O /tmp/${FLEET_TAR} ${FLEET_URL} && \
14+
cd /tmp && \
15+
tar -xzvf ${FLEET_TAR} && \
16+
cp $(basename ${FLEET_TAR} .tar.gz)/fleetctl /usr/local/bin/fleetctl
17+
18+
# Download the kubectl binary:
19+
ENV KUBE_VER=0.20.2
20+
ENV KUBE_URL=https://storage.googleapis.com/kubernetes-release/release/v${KUBE_VER}/bin/linux/amd64/kubectl
21+
RUN /bin/bash -l -c "wget ${KUBE_URL} \
22+
-O /usr/local/bin/kubectl && \
23+
chmod +x /usr/local/bin/kubectl"
24+
25+
# Add the kb8or files
26+
RUN mkdir /var/lib/kb8or
27+
WORKDIR /var/lib/kb8or
28+
ADD . /var/lib/kb8or/
29+
RUN bundle install
30+
RUN ln -s /var/lib/kb8or/kb8or.rb /usr/local/bin/kb8or
31+
32+
# Add the deploy mount - point
33+
RUN mkdir -p /var/lib/deploy
34+
WORKDIR /var/lib/deploy
35+
VOLUME /var/lib/deploy
36+
37+
CMD bash

kb8or.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616

1717
require 'methadone'
1818
require 'yaml'
19-
Dir.glob(File.join(File.dirname(__FILE__), 'libs/*.rb')) { |f| require f }
19+
require 'pathname'
20+
21+
KB8_HOME = File.dirname(Pathname.new(__FILE__).realdirpath)
22+
Dir.glob(File.join(KB8_HOME, 'libs/*.rb')) { |f| require f }
2023

2124
class Kb8or
2225
include Methadone::Main
2326
include Methadone::CLILogging
2427

25-
version '0.0.6'
28+
version File.read(File.join(KB8_HOME, 'version'))
2629
description 'Will create OR update a kb8 application in a re-runnable way'
2730

2831
arg :deploy_file

kb8or_jenkins

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
# Example runner - how this could work within Jenkins...
3+
4+
set -e
5+
6+
# TODO: make this more generic!
7+
if [ "$USER" == "JENKINS"]; then
8+
export SUDO="sudo "
9+
fi
10+
11+
# Get the relative checked out code directory in Jenkins:
12+
REAL_ROOT=/var/lib
13+
JENKINS_ROOT=/var
14+
REAL_CODE_HOME=${PWD/$JENKINS_ROOT/$REAL_ROOT}
15+
VER=$(cat version)
16+
17+
# Now run kb8or...
18+
$SUDO docker run -it --rm --name kb8or -v "${REAL_CODE_HOME}":/var/lib/deploys ukhomeofficedigital/kb8or:${VER} && \
19+
kb8or $@

version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.6

0 commit comments

Comments
 (0)