Skip to content

Commit

Permalink
Multi architecture docker (#110)
Browse files Browse the repository at this point in the history
* initial commit;

* update docker

* update docker config

* update docker config

* update docker config

* update docker config

* update docker config

* update docker config

* update docker config

* update docker config

* initial commit;

* update docker

* update docker config

* update docker config

* update docker config

* update docker config

* update docker config

* update docker config

* update docker config

* update docker config

* add multi arch docker ima support
  • Loading branch information
circa10a authored Jan 16, 2019
1 parent eeef9bc commit 1327eb7
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
sudo: true
language: python
python:
- 3.6
services:
- docker
addons:
apt:
packages:
- docker-ce

script:
- pip install flake8 && flake8 *.py pyouroboros/
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
FROM python:3.7-alpine

COPY / /app

WORKDIR /app

COPY . .
RUN apk add --no-cache tzdata && \
pip install --no-cache-dir .

ENTRYPOINT ["ouroboros"]
2 changes: 1 addition & 1 deletion Dockerfile-aarch64.rpi → Dockerfile-arm32v7.rpi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM resin/generic-aarch64-alpine-python:3-slim
FROM balenalib/raspberry-pi-alpine-python:3.7

COPY . /app
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-arm.rpi → Dockerfile-arm64v8.rpi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM resin/raspberry-pi-alpine-python:3-slim
FROM balenalib/aarch64-alpine-python:3.7

COPY . /app
WORKDIR /app
Expand Down
15 changes: 1 addition & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,13 @@ More detailed usage and configuration can be found on [the wiki](https://github.

Ouroboros is deployed via docker image like so:

**x86**
```bash
docker run -d --name ouroboros \
-v /var/run/docker.sock:/var/run/docker.sock \
pyouroboros/ouroboros
```

**Rpi 3 B+**
```bash
docker run -d --name ouroboros \
-v /var/run/docker.sock:/var/run/docker.sock \
pyouroboros/ouroboros:latest-aarch64-rpi
```

**All other Rpi's**
```bash
docker run -d --name ouroboros \
-v /var/run/docker.sock:/var/run/docker.sock \
pyouroboros/ouroboros:latest-arm-rpi
```
> This is image is compatible for amd64, arm32v7, and arm64v8 CPU architectures (regular systems and Raspberry Pi's)
or via `docker-compose`:

Expand Down
43 changes: 29 additions & 14 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
#!/usr/bin/env bash -e
VERSION=$(grep -i version ./setup.py | awk -F= '{gsub("\047",""); gsub(",",""); print $2}')
#!/usr/bin/env bash
VERSION="$(grep -i version ./pyouroboros/__init__.py | awk -F= '{gsub("\047",""); gsub(",",""); print $2}')"

# Docker
GITHUB_USER='pyouroboros-bot'
DOCKER_USER='pyouroborosbot'
PROJECT='ouroboros'
NAMESPACE="pyouroboros/${PROJECT}"

# Docker experimental config
echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json
[ -d ~/.docker ] || mkdir ~/.docker
[ -f ~/.docker/config.json ] || touch ~/.docker/config.json
echo '{"experimental":"enabled"}' | sudo tee ~/.docker/config.json
sudo service docker restart

# Auth
echo $DOCKER_PASSWORD | docker login -u="$DOCKER_USER" --password-stdin

# Latest x86
docker build -t $NAMESPACE:latest . && \
docker push $NAMESPACE:latest && \
# Versioned x86
docker tag $NAMESPACE:latest $NAMESPACE:$VERSION && \
docker push $NAMESPACE:$VERSION
# Latest x64
docker build -t "${NAMESPACE}:latest" . && \
docker push "${NAMESPACE}:latest" && \
# Versioned x64
docker tag "${NAMESPACE}:latest" "${NAMESPACE}:${VERSION}" && \
docker push "${NAMESPACE}:${VERSION}" && \
# x64 Arch
docker tag "${NAMESPACE}:latest" "${NAMESPACE}:latest-amd64" && \
docker push "${NAMESPACE}:latest-amd64"

# prepare qemu for ARM builds
# Prepare qemu for ARM builds
docker run --rm --privileged multiarch/qemu-user-static:register --reset

# ARM images
for i in $(ls *.rpi); do
ARCH="$(echo ${i} | cut -d- -f2 | cut -d. -f1)"
arch="$(echo ${i} | cut -d- -f2 | cut -d. -f1)"
# Latest
docker build -f "./Dockerfile-${ARCH}.rpi" -t "${NAMESPACE}:latest-${ARCH}-rpi" . && \
docker push "${NAMESPACE}:latest-${ARCH}-rpi" && \
docker build -f "./Dockerfile-${arch}.rpi" -t "${NAMESPACE}:latest-${arch}-rpi" . && \
docker push "${NAMESPACE}:latest-${arch}-rpi" && \
# Versioned
docker tag "${NAMESPACE}:latest-${ARCH}-rpi" "${NAMESPACE}:${VERSION}-${ARCH}-rpi" && \
docker push "${NAMESPACE}:${VERSION}-${ARCH}-rpi"
docker tag "${NAMESPACE}:latest-${arch}-rpi" "${NAMESPACE}:${VERSION}-${arch}-rpi" && \
docker push "${NAMESPACE}:${VERSION}-${arch}-rpi"
done

wget -O manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.9.0/manifest-tool-linux-amd64 && \
chmod +x manifest-tool && \
./manifest-tool --username "$USER" --password "$docker_password" push from-spec "${USER}-${PROJECT}.yaml"
# Git tags
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_API_KEY}@github.com/${NAMESPACE}.git" && \
git tag "${VERSION}" && \
Expand Down
1 change: 1 addition & 0 deletions dev-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dependencies:
- schedule
- prometheus_client
- requests
- influxdb
- flake8
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dependencies:
- schedule
- prometheus_client
- requests
- influxdb
19 changes: 19 additions & 0 deletions pyouroboros-ouroboros.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
image: pyouroboros/ouroboros:latest
manifests:
-
image: pyouroboros/ouroboros:latest-amd64
platform:
architecture: amd64
os: linux
-
image: pyouroboros/ouroboros:latest-arm32v7-rpi
platform:
architecture: arm
variant: v7
os: linux
-
image: pyouroboros/ouroboros:latest-arm64v8-rpi
platform:
architecture: arm64
variant: v8
os: linux

0 comments on commit 1327eb7

Please sign in to comment.