Skip to content

Commit c1addfb

Browse files
author
Ryan Hitchman
committed
Add Docker image for kettle.
1 parent 1d7f254 commit c1addfb

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed

kettle/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build.db
2+

kettle/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM pypy:2
2+
3+
ADD requirements.txt /kettle/
4+
RUN pip install -r /kettle/requirements.txt
5+
6+
RUN apt-get update && apt-get install pv time sqlite3 && apt-get clean
7+
8+
RUN curl -o installer https://sdk.cloud.google.com && bash installer --disable-prompts --install-dir=/ && rm installer && ln -s /google-cloud-sdk/bin/* /bin/
9+
10+
RUN ln -s /data/build.db /kettle/
11+
12+
# stupid hack to deal with debian python2 getsitepackages vs pypy's version
13+
RUN bash -c 'touch /usr/local/site-packages/google/{__init__.py,cloud/__init__.py,cloud/pubsub/__init__.py}'
14+
15+
ADD *.py schema.json runner.sh /kettle/
16+
ADD buckets.yaml /
17+
18+
ENV PYTHONPATH /usr/local/site-packages
19+
CMD ["/kettle/runner.sh"]
20+
VOLUME ["/data"]

kettle/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2016 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
IMG = gcr.io/k8s-testimages/kettle
16+
TAG = $(shell date +v%Y%m%d)-$(shell git describe --tags --always --dirty)
17+
18+
build:
19+
cp ../buckets.yaml .
20+
docker build -t $(IMG):$(TAG) .
21+
rm buckets.yaml
22+
docker tag $(IMG):$(TAG) $(IMG):latest
23+
echo Built $(IMG):$(TAG) and tagged with $(IMG):latest ;
24+
25+
push: build
26+
gcloud docker -- push $(IMG):$(TAG)
27+
gcloud docker -- push $(IMG):latest
28+
echo Pushed $(IMG):latest and $(IMG):$(TAG)
29+
30+
31+
.PHONY: all build push
32+
33+
all: build

kettle/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
requests
12
google-cloud-bigquery
23
google-cloud-pubsub
34
pyyaml

kettle/runner.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# Copyright 2016 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o errexit
17+
set -o nounset
18+
set -o pipefail
19+
20+
# A wrapper script for running kettle
21+
22+
# Update gcloud
23+
gcloud components update
24+
25+
# Authenticate gcloud
26+
if [[ -n "${GOOGLE_APPLICATION_CREDENTIALS:-}" ]]; then
27+
gcloud auth activate-service-account --key-file="${GOOGLE_APPLICATION_CREDENTIALS}"
28+
fi
29+
30+
bq show <<< $'\n' > /dev/null # create initial bq config
31+
32+
while true; do
33+
/kettle/update.py
34+
done

0 commit comments

Comments
 (0)