Skip to content

Commit 5950716

Browse files
authored
Dapper base image (#37)
Add dapper base-image and deployment logic, using original dapper-base until we have it in quay.
1 parent f090de5 commit 5950716

File tree

5 files changed

+137
-2
lines changed

5 files changed

+137
-2
lines changed

.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ git:
1010

1111
jobs:
1212
include:
13-
- env: CMD="make validate"
13+
- env: CMD="make validate" DEPLOY=true
1414

1515
install:
1616
- sudo apt-get install moreutils # make ts available
@@ -21,3 +21,10 @@ services:
2121
script:
2222
- set -o pipefail;
2323
$CMD 2>&1 | ts '[%H:%M:%.S]' -s
24+
25+
deploy:
26+
- provider: script
27+
script: bash scripts/release
28+
on:
29+
branch: master
30+
condition: $DEPLOY = true

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ TARGETS := $(shell ls scripts)
88
@./.dapper.tmp -v
99
@mv .dapper.tmp .dapper
1010

11-
$(TARGETS): .dapper
11+
shell:
12+
./.dapper -m bind -s
13+
14+
$(TARGETS): .dapper dapper-image
1215
./.dapper -m bind $@
1316

1417
.DEFAULT_GOAL := ci

package/Dockerfile.dapper-base

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
FROM fedora:30
2+
3+
ENV DAPPER_HOST_ARCH=amd64
4+
ENV HOST_ARCH=${DAPPER_HOST_ARCH} ARCH=${DAPPER_HOST_ARCH} \
5+
LINT_VERSION=v1.16.0 \
6+
HELM_VERSION=v2.14.1 \
7+
KIND_VERSION=v0.6.1 \
8+
KUBEFED_VERSION=0.1.0-rc3
9+
10+
ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm=armv6l GOLANG_ARCH=GOLANG_ARCH_${ARCH} \
11+
GOPATH=/go GO111MODULE=on PATH=/go/bin:/usr/local/go/bin:${PATH} SHELL=/bin/bash GOFLAGS=-mod=vendor \
12+
GOPROXY=https://proxy.golang.org
13+
14+
# Requirements:
15+
# Component | Usage
16+
# -----------------------------------------------------------
17+
# gcc | ginkgo
18+
# git | find the workspace root
19+
# curl | download other tools
20+
# moby-engine | Dapper (Docker)
21+
# golang | build
22+
# kubectl | e2e tests (in kubernetes-client)
23+
# golangci-lint | code linting
24+
# helm | e2e tests
25+
# kubefedctl | e2e tests
26+
# kind | e2e tests
27+
# ginkgo | tests
28+
# goimports | code formatting
29+
# make | OLM installation
30+
# findutils | e2e cleanup (xargs)
31+
# upx | binary compression
32+
# jq | JSON processing (GitHub API)
33+
# diffutils | required for goimports
34+
RUN dnf -y distrosync --nodocs --setopt=install_weak_deps=False && \
35+
dnf -y install --nodocs --setopt=install_weak_deps=False gcc git-core curl moby-engine make golang kubernetes-client findutils upx jq && \
36+
dnf -y remove acl dnf-yum langpacks-en libevent libsemanage libsss_idmap libxcrypt-compat mkpasswd openssl python3-pip python3-setuptools \
37+
sssd-client unbound-libs whois-nls && \
38+
rpm -e --nodeps selinux-policy-targeted && \
39+
dnf -y clean all && \
40+
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin ${LINT_VERSION} && \
41+
curl "https://storage.googleapis.com/kubernetes-helm/helm-${HELM_VERSION}-linux-${ARCH}.tar.gz" | tar -xzf - && \
42+
mv linux-${ARCH}/helm /usr/bin/ && chmod a+x /usr/bin/helm && rm -rf linux-${ARCH} && \
43+
curl -L "https://github.com/kubernetes-sigs/kubefed/releases/download/v${KUBEFED_VERSION}/kubefedctl-${KUBEFED_VERSION}-linux-${ARCH}.tgz" | tar -xzf - && \
44+
mv kubefedctl /usr/bin/ && chmod a+x /usr/bin/kubefedctl && \
45+
curl -Lo /usr/bin/kind "https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-${ARCH}" && chmod a+x /usr/bin/kind && \
46+
GOFLAGS="" go get -v github.com/onsi/ginkgo/ginkgo && \
47+
GOFLAGS="" go get -v golang.org/x/tools/cmd/goimports && \
48+
upx /go/bin/ginkgo /go/bin/goimports /go/bin/golangci-lint /usr/bin/containerd /usr/bin/docker /usr/bin/dockerd /usr/bin/helm /usr/bin/kubectl \
49+
/usr/bin/kubefedctl && \
50+
ln -f /usr/bin/kubectl /usr/bin/hyperkube
51+
52+
# Copy CI deployment scripts into image to share with all submariner-io/* projects
53+
# TODO: uncomment when we have the scripts
54+
#WORKDIR /opt/kind-e2e
55+
#COPY scripts/kind-e2e/ .

scripts/dapper-image

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
set -e
3+
4+
#
5+
# The purpose of this script is to ensure that dapper-base:latest is updated and available locally
6+
# and if dapper-base is modified we make sure it's rebuilt and tagged locally so any next
7+
# execution through dapper will have the new image.
8+
#
9+
10+
source $(dirname $0)/lib/debug_functions
11+
source $(dirname $0)/lib/version
12+
13+
ARCH=${ARCH:-"amd64"}
14+
SUFFIX=""
15+
[ "${ARCH}" != "amd64" ] && SUFFIX="_${ARCH}"
16+
17+
TAG=${TAG:-${VERSION}${SUFFIX}}
18+
REPO=${REPO:-quay.io/submariner}
19+
20+
DAPPER_BASE_IMAGE=${REPO}/shipyard-dapper-base:${TAG}
21+
22+
# always compare with upstream master, which is the source for the published dapper image
23+
UPSTREAM_REMOTE=$(git remote -v | grep submariner-io/shipyard | awk '{ print $1 }' | head -n 1)
24+
CHANGED_FILES_LOCAL=$(git diff --name-only remotes/$UPSTREAM_REMOTE/master)
25+
26+
# Detect when we are on a merged patch
27+
LAST_COMMIT_LOCAL=$(git rev-parse HEAD)
28+
LAST_COMMIT_MASTER=$(git rev-parse remotes/$UPSTREAM_REMOTE/master)
29+
30+
31+
32+
if [[ "${CHANGED_FILES_PR[@]}" =~ "package/Dockerfile.dapper-base" ]] ||
33+
[[ "${CHANGED_FILES_LOCAL[@]}" =~ "package/Dockerfile.dapper-base" ]] ||
34+
[[ "${LAST_COMMIT_LOCAL}" == "${LAST_COMMIT_MASTER}" ]]; then
35+
echo "Dockerfile.dapper-base was modified, rebuilding dapper image"
36+
docker build -t ${DAPPER_BASE_IMAGE} -f package/Dockerfile.dapper-base .
37+
docker tag ${DAPPER_BASE_IMAGE} ${REPO}/shipyard-dapper-base:latest
38+
else
39+
docker pull ${REPO}/shipyard-dapper-base:latest || :
40+
# make sure the tag is also available for release, even if no changes happened
41+
docker tag ${REPO}/shipyard-dapper-base:latest ${DAPPER_BASE_IMAGE}
42+
fi
43+
44+

scripts/release

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
DEPLOY="${DEPLOY:-false}"
5+
6+
7+
source $(dirname $0)/lib/debug_functions
8+
source $(dirname $0)/lib/version
9+
10+
11+
# This flag is passed from travis, so only the right jobs will deploy the
12+
# container images to quay
13+
14+
if [ "$DEPLOY" != "true" ] ; then
15+
echo "We don't need to deploy from this job, if you're trying to deploy manually set DEPLOY=true"
16+
exit 0
17+
fi
18+
19+
20+
DOCKER_TAG=${1:-latest}
21+
REPO=${REPO:-quay.io/submariner}
22+
23+
echo "$QUAY_PASSWORD" | docker login quay.io -u "$QUAY_USERNAME" --password-stdin
24+
docker tag ${REPO}/shipyard-dapper-base:${VERSION} ${REPO}/shipyard-dapper-base:${DOCKER_TAG#"v"}
25+
docker tag ${REPO}/shipyard-dapper-base:${VERSION} ${REPO}/shipyard-dapper-base:"${TRAVIS_COMMIT:0:7}"
26+
for i in $(docker images --format "{{.Repository}}:{{.Tag}}" | grep -E "${REPO}/.*:(${DOCKER_TAG#v}|${TRAVIS_COMMIT:0:7})"); do docker push $i; done

0 commit comments

Comments
 (0)