From c8c2e8b7f6097dbeaf7039b94f656fd30aba8945 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Mon, 16 Jan 2017 18:22:51 +0100 Subject: [PATCH] Dockerfile for running tests --- script/test_in_container/Dockerfile | 46 +++++++++++++++++++++++++++++ script/test_in_container/run.sh | 25 ++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 script/test_in_container/Dockerfile create mode 100755 script/test_in_container/run.sh diff --git a/script/test_in_container/Dockerfile b/script/test_in_container/Dockerfile new file mode 100644 index 00000000..6d8c09d5 --- /dev/null +++ b/script/test_in_container/Dockerfile @@ -0,0 +1,46 @@ +# 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. + + +# This Dockefile creates image where all Kompose tests can be run + +FROM registry.centos.org/centos/centos:7 + +RUN yum install -y epel-release +RUN yum install -y golang make git jq &&\ + yum -y clean all + +ENV GOPATH="/opt/go" \ + # KOMPOSE_TMP_SRC is where kompose source will be mounted from host + KOMPOSE_TMP_SRC="/opt/tmp/kompose" + +ENV PATH="$PATH:$GOPATH/bin" \ + # KOMPOSE_SRC is where kompose source will be copied when container starts (by run.sh script) + # this is to ensure that we won't write anything to host volume mount + KOMPOSE_SRC="$GOPATH/src/github.com/kubernetes-incubator/kompose" + +RUN go get github.com/Masterminds/glide &&\ + go get github.com/sgotti/glide-vc &&\ + go get github.com/golang/lint/golint + +WORKDIR $KOMPOSE_SRC +# This image can be run as any user +RUN chmod -R ugo+rw $GOPATH + + +COPY run.sh /opt/tools/ +ENTRYPOINT ["/opt/tools/run.sh"] + + + diff --git a/script/test_in_container/run.sh b/script/test_in_container/run.sh new file mode 100755 index 00000000..892222b0 --- /dev/null +++ b/script/test_in_container/run.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +# Copyright 2017 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. + + +# Container should be started with Kompose source mounted as read-only volume $KOMPOSE_TMP_SRC +# Copy Kompose sources to another directory after container starts. +# We can be sure that this container won't modify any files on hosts disk. +cp -r $KOMPOSE_TMP_SRC/ $(dirname $KOMPOSE_SRC) + +make test-all