diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml new file mode 100644 index 00000000..c899776f --- /dev/null +++ b/.buildkite/pipeline.yml @@ -0,0 +1,16 @@ +steps: + - label: Go version + command: go version + + - label: Docker version + command: docker version + + - label: Install tools + command: + - GOPATH=~/go ./build/install-build-tools.sh + + - wait + + - label: Build containerd arm64 deb package + command: + - GOOS=linux GOARCH=arm64 GOOS=linux GOARCH=arm64 ./deps/publish-all.sh \ No newline at end of file diff --git a/.circleci/config.yml b/.circleci/config.yml index 47cb06a8..cf68f6a3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,28 +27,15 @@ jobs: - checkout - setup_remote_docker - - run: - name: Install tools - command: | - go get github.com/goreleaser/goreleaser - # Switch to fixed fork - cd /go/src/github.com/goreleaser/goreleaser - git remote add ernoaapa https://github.com/ernoaapa/goreleaser.git - git fetch ernoaapa - git checkout fix-arm-architecture - GOBIN=/go/bin go install . + - run: ./build/install-build-tools.sh - go get github.com/mlafeldt/pkgcloud/... - - run: sudo apt-get update && sudo apt-get install -y btrfs-tools libseccomp-dev - - run: ./build/build-containerd-and-runc.sh - run: goreleaser --snapshot - run: name: Publish Linux packages command: | - pkgcloud-push ernoaapa/eliot/raspbian/stretch dist/eliot_*_linux_amd64.deb - pkgcloud-push ernoaapa/eliot/raspbian/stretch dist/eliot_*_linux_arm64.deb - pkgcloud-push ernoaapa/eliot/raspbian/stretch dist/eliot_*_linux_armv6.deb - pkgcloud-push ernoaapa/eliot/raspbian/stretch dist/eliot_*_linux_armv7.deb + for package in dist/eliot_*.deb; do + pkgcloud-push ernoaapa/eliot/raspbian/stretch $package + done publish: <<: *defaults @@ -60,27 +47,37 @@ jobs: name: Login Docker hub command: echo $DOCKER_PASS | docker login --username $DOCKER_USER --password-stdin - - run: - name: Install tools - command: | - go get github.com/goreleaser/goreleaser - go get github.com/estesp/manifest-tool - go get github.com/mlafeldt/pkgcloud/... + - run: ./build/install-build-tools.sh - - run: sudo apt-get update && sudo apt-get install -y btrfs-tools libseccomp-dev - - run: ./build/build-containerd-and-runc.sh - run: goreleaser - run: .circleci/scripts/push-docker-manifest.sh $(git describe --tags --always --dirty) - run: name: Publish Linux packages command: | - pkgcloud-push ernoaapa/eliot/raspbian/stretch dist/eliot_*_linux_amd64.deb - pkgcloud-push ernoaapa/eliot/raspbian/stretch dist/eliot_*_linux_arm64.deb - pkgcloud-push ernoaapa/eliot/raspbian/stretch dist/eliot_*_linux_armv6.deb - pkgcloud-push ernoaapa/eliot/raspbian/stretch dist/eliot_*_linux_armv7.deb + for package in dist/eliot_*.deb; do + pkgcloud-push ernoaapa/eliot/raspbian/stretch $package + done + + deps_build_and_release: + <<: *defaults + steps: + - checkout + - run: ./build/install-build-tools.sh + + - run: + name: Install build dependencies + command: sudo apt-get update && sudo apt-get install -y btrfs-tools libseccomp-dev + + - run: + name: build & release deps + command: GOOS=linux GOARCH=amd64 ./deps/publish-all.sh workflows: version: 2 + deps: + jobs: + - deps_build_and_release + build_and_test: jobs: - test: diff --git a/.goreleaser.yml b/.goreleaser.yml index 58f30bb6..2f437134 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -76,16 +76,8 @@ nfpm: formats: - deb - # At the moment repositories includes really old version of containerd - # so we bake in the containerd daemon and runc binary - # dependencies: - # - containerd@v1.0.3 dependencies: - - libseccomp2 #(Actually runc dep) + - containerd (>= 1.0.3) files: "build/etc/systemd/system/eliotd.service": "/etc/systemd/system/eliotd.service" - "build/etc/systemd/system/containerd.service": "/etc/systemd/system/containerd.service" - # Built during the build process - "bin/runc": "/usr/local/bin/runc" - "bin/containerd": "/usr/local/bin/containerd" diff --git a/build/build-containerd-and-runc.sh b/build/build-containerd-and-runc.sh deleted file mode 100755 index 9b38b42a..00000000 --- a/build/build-containerd-and-runc.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# - -set -eu - -CONTAINERD_VERSION="v1.0.3" -RUNC_VERSION="v0.1.1" -BUILD_DIR=/tmp/build -TARGET_DIR=$(pwd)/bin - -mkdir -p $TARGET_DIR - -# CONTAINERD -echo "Build containerd" -rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR}/src/github.com/containerd/containerd -wget -qO- "https://github.com/containerd/containerd/archive/${CONTAINERD_VERSION}.tar.gz" | tar xvz --strip-components=1 -C ${BUILD_DIR}/src/github.com/containerd/containerd -cd ${BUILD_DIR}/src/github.com/containerd/containerd -# Modify Makefile to have optional VERSION and REVISION -sed -i='' 's/VERSION=/VERSION?=/g' Makefile -sed -i='' 's/REVISION=/REVISION?=/g' Makefile -GOPATH=${BUILD_DIR} VERSION=${CONTAINERD_VERSION} REVISION=unknown make binaries -cp bin/containerd ${TARGET_DIR} -cp bin/ctr ${TARGET_DIR} -cp bin/containerd-shim ${TARGET_DIR} - -# RUNC -echo "Build runc" -rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR}/src/github.com/opencontainers/runc -wget -qO- "https://github.com/opencontainers/runc/archive/${RUNC_VERSION}.tar.gz" | tar xvz --strip-components=1 -C ${BUILD_DIR}/src/github.com/opencontainers/runc -cd ${BUILD_DIR}/src/github.com/opencontainers/runc -make -cp runc ${TARGET_DIR} diff --git a/build/install-build-tools.sh b/build/install-build-tools.sh new file mode 100755 index 00000000..686483f4 --- /dev/null +++ b/build/install-build-tools.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -eu + +go get -u github.com/goreleaser/goreleaser +# Switch to fixed fork +cd $GOPATH/src/github.com/goreleaser/goreleaser +git remote add ernoaapa https://github.com/ernoaapa/goreleaser.git || true +git fetch ernoaapa +git checkout fix-arm-architecture +GOBIN=$GOPATH/bin go install . + +go get -u github.com/goreleaser/nfpm +# Switch to fixed fork +cd $GOPATH/src/github.com/goreleaser/nfpm +git remote add ernoaapa https://github.com/ernoaapa/nfpm.git || true +git fetch ernoaapa +git checkout fix-arm-architecture +GOBIN=$GOPATH/bin go install ./cmd/nfpm/ + +go get github.com/estesp/manifest-tool +go get github.com/mlafeldt/pkgcloud/... \ No newline at end of file diff --git a/deps/README.md b/deps/README.md new file mode 100644 index 00000000..c2489d2b --- /dev/null +++ b/deps/README.md @@ -0,0 +1,3 @@ +# DEPS + +This directory contains all scripts to build containerd and runc dependencies \ No newline at end of file diff --git a/deps/build-containerd.sh b/deps/build-containerd.sh new file mode 100755 index 00000000..42be609f --- /dev/null +++ b/deps/build-containerd.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# +# + +set -eu + +CONTAINERD_VERSION="v1.0.3" +BUILD_DIR=/tmp/build +ELIOT_SRC_DIR=$(pwd) +TARGET_DIR=${ELIOT_SRC_DIR}/dist +GOOS=${GOOS-"linux"} +GOARCH=${GOARCH} # required +GOARM=${GOARM:-""} # optional + +mkdir -p $TARGET_DIR + +rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR}/src/github.com/containerd/containerd +wget -qO- "https://github.com/containerd/containerd/archive/${CONTAINERD_VERSION}.tar.gz" | tar xvz --strip-components=1 -C ${BUILD_DIR}/src/github.com/containerd/containerd +cd ${BUILD_DIR}/src/github.com/containerd/containerd +# Modify Makefile to have optional VERSION and REVISION +sed -i='' 's/VERSION=/VERSION?=/g' Makefile +sed -i='' 's/REVISION=/REVISION?=/g' Makefile + +echo "Compile containerd os:${GOOS}, arch:${GOARCH}, variant:${GOARM}" +GOPATH=${BUILD_DIR} VERSION=${CONTAINERD_VERSION} REVISION=unknown make binaries + +cat << EOF > ./nfpm.yaml +name: "containerd" +arch: "${GOARCH}${GOARM:-""}" +platform: "${GOOS}" +version: "${CONTAINERD_VERSION}" +section: "default" +priority: "extra" +depends: +- runc (>=0.1.1) +maintainer: "Erno Aapa " +description: An open and reliable container runtime +homepage: "https://containerd.io" +license: "Apache 2.0" +bindir: "/usr/local/bin" +files: + ./bin/containerd: "/usr/local/bin/containerd" + ./bin/ctr: "/usr/local/bin/ctr" + ./bin/containerd-shim: "/usr/local/bin/containerd-shim" + ${ELIOT_SRC_DIR}/build/etc/systemd/system/containerd.service: "/etc/systemd/system/containerd.service" +EOF + +nfpm pkg --target ${TARGET_DIR}/containerd_${CONTAINERD_VERSION}_${GOOS}_${GOARCH}${GOARM:-""}.deb diff --git a/deps/build-runc.sh b/deps/build-runc.sh new file mode 100755 index 00000000..7041be7b --- /dev/null +++ b/deps/build-runc.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# +# + +set -eu + +RUNC_VERSION="v0.1.1" +BUILD_DIR=/tmp/build +TARGET_DIR=$(pwd)/dist +GOOS=${GOOS-"linux"} +GOARCH=${GOARCH} # required +GOARM=${GOARM:-""} # optional + +mkdir -p $TARGET_DIR + +rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR}/src/github.com/opencontainers/runc +wget -qO- "https://github.com/opencontainers/runc/archive/${RUNC_VERSION}.tar.gz" | tar xvz --strip-components=1 -C ${BUILD_DIR}/src/github.com/opencontainers/runc +cd ${BUILD_DIR}/src/github.com/opencontainers/runc + +echo "Build runc os:${GOOS}, arch:${GOARCH}, variant:${GOARM}" +GOPATH=${BUILD_DIR} make + +cat << EOF > ./nfpm.yaml +name: "runc" +arch: "${GOARCH}${GOARM:-""}" +platform: "${GOOS}" +version: "${RUNC_VERSION}" +section: "default" +priority: "extra" +depends: +- libseccomp2 +maintainer: "Erno Aapa " +description: runc is a CLI tool for spawning and running containers according to the OCI specification. +homepage: "https://www.opencontainers.org" +license: "Apache 2.0" +bindir: "/usr/local/bin" +files: + ./runc: "/usr/local/bin/runc" +EOF + +nfpm pkg --target ${TARGET_DIR}/runc_${RUNC_VERSION}_${GOOS}_${GOARCH}${GOARM:-""}.deb diff --git a/deps/publish-all.sh b/deps/publish-all.sh new file mode 100755 index 00000000..f9b12e51 --- /dev/null +++ b/deps/publish-all.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -eu + +BASEDIR=$(dirname "$0") +if [ -z ${PACKAGECLOUD_TOKEN+x} ]; then + echo "You must define PACKAGECLOUD_TOKEN environment variable to publish packages" + exit 1 +fi + +rm -rf ./dist +${BASEDIR}/build-containerd.sh +${BASEDIR}/build-runc.sh + +for package in dist/*.deb; do + pkgcloud-push ernoaapa/eliot/raspbian/stretch $package || echo "${package} upload failed. Already uploaded?" +done \ No newline at end of file