Skip to content

Commit

Permalink
Merge pull request #39 from ernoaapa/build-packages
Browse files Browse the repository at this point in the history
Build deb packages
  • Loading branch information
ernoaapa authored Apr 18, 2018
2 parents f3fd627 + e0734fc commit 35a0dc3
Show file tree
Hide file tree
Showing 17 changed files with 277 additions and 20 deletions.
16 changes: 16 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 28 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ jobs:
- checkout
- setup_remote_docker

- run: go get github.com/goreleaser/goreleaser
- run: ./build/install-build-tools.sh

- run: goreleaser --snapshot

publish:
Expand All @@ -40,16 +41,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
- run: ./build/install-build-tools.sh

- run: goreleaser
- run: .circleci/scripts/push-docker-manifest.sh $(git describe --tags --always --dirty)
- run:
name: Publish Linux packages
command: |
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:
Expand Down
27 changes: 27 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ builds:
goarch:
- amd64
- arm64
- arm
goarm:
- 6
- 7

env:
- CGO_ENABLED=0

Expand All @@ -17,6 +22,11 @@ builds:
goarch:
- amd64
- arm64
- arm
goarm:
- 6
- 7

env:
- CGO_ENABLED=0

Expand Down Expand Up @@ -57,3 +67,20 @@ dockers:
dockerfile: Dockerfile.eliotd
tag_templates:
- "v{{ .Version }}-arm64"

nfpm:
homepage: http://www.eliot.run
maintainer: Erno Aapa <[email protected]>
description: "Container management system for IoT devices"
license: Apache 2.0
formats:
- deb

dependencies:
- containerd (>= 1.0.3)

files:
"build/etc/systemd/system/eliotd.service": "/etc/systemd/system/eliotd.service"

config_files:
"build/etc/eliotd/config": "/etc/eliotd/config"
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

![Eliot](docs/eliot-logo-medium.png) [![Go Report Card](https://goreportcard.com/badge/github.com/ernoaapa/eliot)](https://goreportcard.com/report/github.com/ernoaapa/eliot)
![Eliot](docs/eliot-logo-medium.png)

[![Go Report Card](https://goreportcard.com/badge/github.com/ernoaapa/eliot)](https://goreportcard.com/report/github.com/ernoaapa/eliot)[![Go Report Card](https://img.shields.io/badge/deb-packagecloud.io-844fec.svg)](https://packagecloud.io/ernoaapa/eliot)

> This is early alpha version! There's not all features yet implemented, not heavily tested with different devices and code might get large breaking changes until the first release.
Expand Down
1 change: 1 addition & 0 deletions build/docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Small script to build and update documentation to GitHub Pages
#
set -euo pipefail

rm -rf _book
gitbook install
Expand Down
1 change: 1 addition & 0 deletions build/etc/eliotd/config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ELIOT_GRPC_API_LISTEN=0.0.0.0:5000
14 changes: 14 additions & 0 deletions build/etc/systemd/system/containerd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Containerd
Documentation=https://github.com/containerd/containerd
Requires=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/local/bin/containerd
Restart=always
KillMode=process
RestartSec=10

[Install]
WantedBy=default.target
15 changes: 15 additions & 0 deletions build/etc/systemd/system/eliotd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Eliot daemon
Documentation=https://github.com/ernoaapa/eliot
Requires=containerd.service
After=containerd.service

[Service]
EnvironmentFile=/etc/eliotd/config
ExecStart=/usr/local/bin/eliotd
Restart=always
KillMode=process
RestartSec=2

[Install]
WantedBy=default.target
22 changes: 22 additions & 0 deletions build/install-build-tools.sh
Original file line number Diff line number Diff line change
@@ -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/...
3 changes: 3 additions & 0 deletions deps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DEPS

This directory contains all scripts to build containerd and runc dependencies
48 changes: 48 additions & 0 deletions deps/build-containerd.sh
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"
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
41 changes: 41 additions & 0 deletions deps/build-runc.sh
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"
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
17 changes: 17 additions & 0 deletions deps/publish-all.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* [Use Cases](introduction.md#use-cases)
* [Eliot vs. Other](introduction.md#eliot-vs-other)
* [Installation](installation.md)
* [Install Eliot client](installation.md#install-eliot-client)
* [Install EliotOS](installation.md#install-eliotos)
* [Install CLI](installation.md#install-cli)
* [Install device](installation.md#install-device)
* [Getting Started](getting_started.md)
* [Core Concepts](getting_started.md#core-concepts)
* [Deploy first app](getting_started.md#deploy-first-app)
Expand Down
2 changes: 1 addition & 1 deletion docs/eliotos.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# EliotOS
EliotOS is minimal Linux Operating System, built with [Linuxkit](https://github.com/linuxkit/linuxkit), which contains only minimal components to run Eliot.
EliotOS is minimal Linux Operating System, built with [Linuxkit](https://github.com/linuxkit/linuxkit), which contains only minimal components to run Eliot. At the moment, EliotOS supports only RaspberryPI3.

- `Linux kernel`
- `containerd` - Container runtime
Expand Down
42 changes: 33 additions & 9 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Installation
> At the moment Eliot is tested only on RaspberryPI 3b with [EliotOS](eliotos.md) but installing it to other environments should be pretty straight forward. If you happen to test in some other device, [please let us know!](https://github.com/ernoaapa/eliot/issues/new)
> At the moment Eliot is tested only on RaspberryPI 3b, but installing it to other environments should be pretty straight forward. If you happen to test in some other device, [please let us know!](https://github.com/ernoaapa/eliot/issues/new)
## Install Eliot client
## Install CLI
Eliot client, called `eli`, is just a binary what you can download from [Eliot releases](https://github.com/ernoaapa/eliot/releases).

### MacOS
Expand All @@ -13,11 +13,16 @@ Eliot client, called `eli`, is just a binary what you can download from [Eliot r
2. Place it into your $PATH
3. Test `eli --version`

## Install EliotOS
By far the easiest and most secure way to use Eliot is by using [EliotOS](eliotos.md). EliotOS is minimal Linux Operating System, built with [linuxkit](https://github.com/linuxkit/linuxkit), which contains only minimal components to run Eliot which are Linux kernel, `runc`, `containerd` and `eliotd` daemon. Check the [EliotOS](eliotos.md) section for more info.
## Install device
There's three options for device installation

1. [Use EliotOS on RaspberryPI 3](/installation.html#eliotos-on-raspberrypi3)
2. [Use Debian linux (e.g. Raspbian) and use deb packages](/installation.html#debian-raspbian-installation)
3. [Manual installation to any linux](/installation.html#manual-installation)

### EliotOS on RaspberryPI3
By far the easiest and most secure way to use Eliot is by using [EliotOS](eliotos.md). EliotOS is minimal Linux Operating System, built with [linuxkit](https://github.com/linuxkit/linuxkit), which contains only minimal components to run Eliot which are Linux kernel, `runc`, `containerd` and `eliotd` daemon. Check the [EliotOS](eliotos.md) section for more info.

### RaspberryPI 3
`eli` provides [build command](client.md#eli-build-device) to build [EliotOS](eliotos.md) for RaspberryPI3 and install it to the sdcard.

1. Format sdcard as you would normally
Expand All @@ -30,7 +35,26 @@ By far the easiest and most secure way to use Eliot is by using [EliotOS](elioto

Next step is to follow [getting started guide](getting_started.md#deploy-first-app) and deploy first app!

## Manual installation
- Install and run [runc](https://github.com/opencontainers/runc)
- Install and run [containerd](https://github.com/containerd/containerd)
- Install and run [eliotd](https://github.com/ernoaapa/eliot)
### Debian (Raspbian) installation
Eliot provides deb packages through packagecloud for Debian linux, for example Raspbian, to install Eliot and all dependencies.

<a href="https://packagecloud.io/ernoaapa/eliot"><img height="46" width="158" alt="Eliot DEB Repository · packagecloud" src="https://packagecloud.io/images/packagecloud-badge.png" /></a>

```shell
# Install eliot deb repository
curl -s https://packagecloud.io/install/repositories/ernoaapa/eliot/script.deb.sh | sudo bash

# Install Eliot and dependencies
apt-get update && apt-get install -y eliot

# Start the services
systemctl start containerd && systemctl enable containerd
systemctl start eliotd && systemctl enable eliotd
```

That's it! Now try running `eli get nodes` and you should see your device!

### Manual installation
- Build and install [runc](https://github.com/opencontainers/runc)
- Build and install and run [containerd](https://github.com/containerd/containerd)
- Build and install and run [eliotd](https://github.com/ernoaapa/eliot)
6 changes: 5 additions & 1 deletion examples/hello-world.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ metadata:
spec:
containers:
- name: "hello-world"
image: "docker.io/eaapa/hello-world:latest"
image: "docker.io/arm32v7/busybox:latest"
args:
- /bin/sh
- -c
- "while true; echo 'Eliot Rocks!'; do sleep 1; done;"

0 comments on commit 35a0dc3

Please sign in to comment.