Skip to content

Commit

Permalink
Add Docker image for kettle.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Hitchman committed Jul 14, 2017
1 parent 1d7f254 commit c1addfb
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kettle/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build.db

20 changes: 20 additions & 0 deletions kettle/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM pypy:2

ADD requirements.txt /kettle/
RUN pip install -r /kettle/requirements.txt

RUN apt-get update && apt-get install pv time sqlite3 && apt-get clean

RUN curl -o installer https://sdk.cloud.google.com && bash installer --disable-prompts --install-dir=/ && rm installer && ln -s /google-cloud-sdk/bin/* /bin/

RUN ln -s /data/build.db /kettle/

# stupid hack to deal with debian python2 getsitepackages vs pypy's version
RUN bash -c 'touch /usr/local/site-packages/google/{__init__.py,cloud/__init__.py,cloud/pubsub/__init__.py}'

ADD *.py schema.json runner.sh /kettle/
ADD buckets.yaml /

ENV PYTHONPATH /usr/local/site-packages
CMD ["/kettle/runner.sh"]
VOLUME ["/data"]
33 changes: 33 additions & 0 deletions kettle/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

IMG = gcr.io/k8s-testimages/kettle
TAG = $(shell date +v%Y%m%d)-$(shell git describe --tags --always --dirty)

build:
cp ../buckets.yaml .
docker build -t $(IMG):$(TAG) .
rm buckets.yaml
docker tag $(IMG):$(TAG) $(IMG):latest
echo Built $(IMG):$(TAG) and tagged with $(IMG):latest ;

push: build
gcloud docker -- push $(IMG):$(TAG)
gcloud docker -- push $(IMG):latest
echo Pushed $(IMG):latest and $(IMG):$(TAG)


.PHONY: all build push

all: build
1 change: 1 addition & 0 deletions kettle/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
requests
google-cloud-bigquery
google-cloud-pubsub
pyyaml
34 changes: 34 additions & 0 deletions kettle/runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

# A wrapper script for running kettle

# Update gcloud
gcloud components update

# Authenticate gcloud
if [[ -n "${GOOGLE_APPLICATION_CREDENTIALS:-}" ]]; then
gcloud auth activate-service-account --key-file="${GOOGLE_APPLICATION_CREDENTIALS}"
fi

bq show <<< $'\n' > /dev/null # create initial bq config

while true; do
/kettle/update.py
done

0 comments on commit c1addfb

Please sign in to comment.