From c1dca04423d665a87ca0462668ac8a9fb1a1ea76 Mon Sep 17 00:00:00 2001 From: Bassam Tabbara Date: Fri, 14 Oct 2016 16:35:37 -0700 Subject: [PATCH] Use alpine linux in all containers We know use alpine linux in containers to bring a few tool dependencies we need including lsblk and others. We know generate ACIs from docker containers instead of creating ACIs with acbuild. --- .gitignore | 13 ++--- build/cross-image/Dockerfile | 7 ++- build/cross-image/version | 2 +- build/makelib/release.mk | 2 +- build/release/aci.sh | 57 --------------------- build/release/binaries.sh | 58 ++++++++++++++++++++++ build/release/{docker.sh => containers.sh} | 15 +++++- build/release/release.sh | 37 ++++++++++++++ demo/vagrant/cloud-config.yml.in | 2 +- 9 files changed, 124 insertions(+), 69 deletions(-) delete mode 100755 build/release/aci.sh create mode 100755 build/release/binaries.sh rename build/release/{docker.sh => containers.sh} (73%) create mode 100755 build/release/release.sh diff --git a/.gitignore b/.gitignore index 5da13fb3c..3f42f554e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,12 @@ -.glide -.work/ .vscode/ -bin/ -release/ -tools/ -vendor/ +/.glide +/.work + +/bin +/tools +/vendor +/release coverage.out coverage.html diff --git a/build/cross-image/Dockerfile b/build/cross-image/Dockerfile index ced8571fd..7e5c7c7ed 100644 --- a/build/cross-image/Dockerfile +++ b/build/cross-image/Dockerfile @@ -49,10 +49,13 @@ RUN OSXCROSS_COMMIT_HASH=86879571d33ff7252a55d777609742561dba9953 && \ ENV PATH /usr/local/osxcross/bin:$PATH -# install acbuild +# install acbuild and docker2aci RUN ACBUILD_VERSION=0.4.0 && \ curl -fsSLO https://github.com/containers/build/releases/download/v${ACBUILD_VERSION}/acbuild-v${ACBUILD_VERSION}.tar.gz && \ - tar -C /usr/local/bin --strip-components=1 -xzf acbuild-v${ACBUILD_VERSION}.tar.gz + tar -C /usr/local/bin --strip-components=1 -xzf acbuild-v${ACBUILD_VERSION}.tar.gz && \ + DOCKER2ACI_VERSION=0.12.3 && \ + curl -fsSLO https://github.com/appc/docker2aci/releases/download/v${DOCKER2ACI_VERSION}/docker2aci-v${DOCKER2ACI_VERSION}.tar.gz && \ + tar -C /usr/local/bin --strip-components=1 -xzf docker2aci-v${DOCKER2ACI_VERSION}.tar.gz # # install multi-arch packages needed to build ceph diff --git a/build/cross-image/version b/build/cross-image/version index 7693c96bf..446ba66e7 100644 --- a/build/cross-image/version +++ b/build/cross-image/version @@ -1 +1 @@ -0.1.3 \ No newline at end of file +0.1.4 \ No newline at end of file diff --git a/build/makelib/release.mk b/build/makelib/release.mk index 6eb4ff143..0d650aedf 100644 --- a/build/makelib/release.mk +++ b/build/makelib/release.mk @@ -28,7 +28,7 @@ RELEASE_CLIENT_ONLY_PLATFORMS ?= RELEASE_HOST_PLATFORM ?= $(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH) # Optional. the flavors to release -RELEASE_FLAVORS := binaries docker aci +RELEASE_FLAVORS := binaries containers # Optional. Github token repo and user GITHUB_TOKEN ?= diff --git a/build/release/aci.sh b/build/release/aci.sh deleted file mode 100755 index e489c6e26..000000000 --- a/build/release/aci.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -e - -scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source ${scriptdir}/common.sh - -container=quantum.com/castled - -build() { - local type=$1 - local os=$2 - local arch=$3 - local version=${RELEASE_VERSION} - - [[ ${type} == "both" ]] || return 0 - - tmpdir=$(mktemp -d) - trap "rm -fr $tmpdir" EXIT - - layout_root $os $arch $tmpdir - - mkdir -p ${RELEASE_DIR} - - local acb="acbuild --debug --work-path $tmpdir" - local acifile=${RELEASE_DIR}/castled-${version}-${os}-${arch}.aci - - echo creating aci file ${acifile} - - ${acb} begin - ${acb} set-name ${container} - for f in $(find $tmpdir/root -maxdepth 1); do - ${acb} copy-to-dir ${f} / - done - ${acb} label add version "$version" - ${acb} set-exec -- /usr/bin/castled - ${acb} write --overwrite ${acifile} - ${acb} end - - rm -fr $tmpdir -} - -publish() { - local type=$1 - local os=$2 - local arch=$3 - local version=${RELEASE_VERSION} - - [[ ${type} == "both" ]] || return 0 - - local aci=${RELEASE_DIR}/castled-${version}-${os}-${arch}.aci - - echo uploading aci file ${acifile} -} - -action=$1 -shift - -${action} "$@" diff --git a/build/release/binaries.sh b/build/release/binaries.sh new file mode 100755 index 000000000..9be8ac32d --- /dev/null +++ b/build/release/binaries.sh @@ -0,0 +1,58 @@ +#!/bin/bash -e + +scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source ${scriptdir}/common.sh + +build() { + local type=$1 + local os=$2 + local arch=$3 + local version=${RELEASE_VERSION} + local bindir=$(get_bindir ${os} ${arch}) + + if [[ ${os} == "windows" ]]; then + local ext=".exe" + fi + + local files=( castlectl${ext} ) + + if [[ ${type} == "both" ]]; then + files+=( castled${ext} ) + fi + + mkdir -p ${RELEASE_DIR} + + if [[ ${os} == "linux" ]]; then + local tarfile=${RELEASE_DIR}/castle-${version}-${os}-${arch}.tar.gz + echo creating tar ${tarfile} + tar czf "${tarfile}" -C "${bindir}" ${files[*]} + else + local zipfile=$(realpath ${RELEASE_DIR}/castle-${version}-${os}-${arch}.zip) + echo creating zip ${zipfile} + $(cd ${bindir} && zip -qr ${zipfile} ${files[*]}) + fi +} + +publish() { + local type=$1 + local os=$2 + local arch=$3 + local version=${RELEASE_VERSION} + + local file=${RELEASE_DIR}/castle-${version}-${os}-${arch} + local ext=tar.gz + local mediatype=gzip + + if [[ ${os} != "linux" ]]; then + ext=zip + mediatype=gzip + fi + + echo uploading $file.$ext to github + github_upload $file.$ext $mediatype +} + +action=$1 +shift + +${action} "$@" diff --git a/build/release/docker.sh b/build/release/containers.sh similarity index 73% rename from build/release/docker.sh rename to build/release/containers.sh index 4982e822d..8c8701dad 100755 --- a/build/release/docker.sh +++ b/build/release/containers.sh @@ -17,9 +17,11 @@ build() { trap "rm -fr $tmpdir" EXIT layout_root $os $arch $tmpdir + mkdir $tmpdir/root/tmp cat < $tmpdir/Dockerfile -FROM scratch +FROM alpine:3.4 +RUN apk add --no-cache gptfdisk util-linux kmod coreutils grep gawk e2fsprogs btrfs-progs sudo COPY root / ENTRYPOINT ["/usr/bin/castled"] EOF @@ -31,6 +33,17 @@ EOF echo building docker container ${tag} docker build -t ${tag} -t quay.io/${tag} $tmpdir + + local file=${tag/\//-} + local file=${file/:/-} + local dockerout=${RELEASE_DIR}/${file}.docker + echo ${file} + + echo generate ACIs from docker containers + docker save -o ${dockerout} ${tag} + docker2aci ${dockerout} + mv *.aci ${RELEASE_DIR} + rm -fr $tmpdir } diff --git a/build/release/release.sh b/build/release/release.sh new file mode 100755 index 000000000..24542a25a --- /dev/null +++ b/build/release/release.sh @@ -0,0 +1,37 @@ +#!/bin/bash -e + +scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source ${scriptdir}/common.sh + +run_platforms() { + local action=${1} + local flavor=${2} + + for p in ${RELEASE_CLIENT_SERVER_PLATFORMS}; do + ${scriptdir}/${flavor}.sh ${action} both ${p%_*} ${p#*_} + done + for p in ${RELEASE_CLIENT_ONLY_PLATFORMS}; do + ${scriptdir}/${flavor}.sh ${action} client ${p%_*} ${p#*_} + done +} + +action=$1 +shift + +case ${action} in + build|publish) + flavor=$1 + shift + + run_platforms ${action} ${flavor} "$@" + ;; + + check) + github_check_release "$@" + ;; + + *) + echo "unknown action ${action}" + exit 1 + ;; +esac diff --git a/demo/vagrant/cloud-config.yml.in b/demo/vagrant/cloud-config.yml.in index dd607034f..e10c5616d 100644 --- a/demo/vagrant/cloud-config.yml.in +++ b/demo/vagrant/cloud-config.yml.in @@ -10,7 +10,7 @@ coreos: # - name: 10-local-aci.conf # content: | # [Service] -# Environment=CASTLED_ACI=/release/castled-dev-linux-amd64.aci +# Environment=CASTLED_ACI=/release/quantum-castled-dev.aci # Environment=RKT_OPTIONS=--insecure-options=image content: | [Unit]