This commit is contained in:
parent
d3e13237f6
commit
d3de286c55
84
.drone.yml
Normal file
84
.drone.yml
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: publish
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- tag
|
||||||
|
refs:
|
||||||
|
- refs/heads/master
|
||||||
|
- refs/tags/v*
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build all binaries
|
||||||
|
image: golang:1.14
|
||||||
|
environment:
|
||||||
|
VERSION: ${DRONE_TAG:-master}
|
||||||
|
commands:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get install -y --no-install-recommends git dmsetup
|
||||||
|
- make all
|
||||||
|
|
||||||
|
- name: push image - arm
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: iamthefij/cadvisor
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: linux-arm
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
build_args:
|
||||||
|
- ARCH=arm
|
||||||
|
- REPO=arm32v7
|
||||||
|
|
||||||
|
- name: push image - arm64
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: iamthefij/cadvisor
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: linux-arm64
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
build_args:
|
||||||
|
- ARCH=arm64
|
||||||
|
- REPO=arm64v8
|
||||||
|
|
||||||
|
- name: push image - amd64
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: iamthefij/cadvisor
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: linux-amd64
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
|
||||||
|
- name: publish manifest
|
||||||
|
image: plugins/manifest
|
||||||
|
settings:
|
||||||
|
spec: manifest.tmpl
|
||||||
|
auto_tag: true
|
||||||
|
ignore_missing: true
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
|
||||||
|
- name: notify
|
||||||
|
image: drillster/drone-email
|
||||||
|
settings:
|
||||||
|
host:
|
||||||
|
from_secret: SMTP_HOST
|
||||||
|
username:
|
||||||
|
from_secret: SMTP_USER
|
||||||
|
password:
|
||||||
|
from_secret: SMTP_PASS
|
||||||
|
from: drone@iamthefij.com
|
||||||
|
when:
|
||||||
|
status: [changed, failure]
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
src/
|
||||||
|
cadvisor-*
|
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
ARG REPO=library
|
||||||
|
FROM multiarch/qemu-user-static:4.2.0-2 as qemu-user-static
|
||||||
|
FROM ${REPO}/alpine:3.10
|
||||||
|
|
||||||
|
# Copying all qemu files because amd64 doesn't exist and cannot condional copy
|
||||||
|
COPY --from=qemu-user-static /usr/bin/qemu-* /usr/bin/
|
||||||
|
|
||||||
|
ARG GOARCH=amd64
|
||||||
|
COPY ./cadvisor-${GOARCH} /usr/bin/cadvisor
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
ENTRYPOINT ["/usr/bin/cadvisor", "-logtostderr"]
|
6
Dockerfile.build-env
Normal file
6
Dockerfile.build-env
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Builder
|
||||||
|
FROM golang:1.14 AS builder
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends git dmsetup && apt-get clean
|
||||||
|
|
||||||
|
WORKDIR /go/src/github.com/google/cadvisor
|
23
Dockerfile.multi-stage
Normal file
23
Dockerfile.multi-stage
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
ARG REPO=library
|
||||||
|
# Builder
|
||||||
|
FROM golang:1.14 AS builder
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends git dmsetup && apt-get clean
|
||||||
|
|
||||||
|
ARG SRC_DIR=./src/cadvisor-master
|
||||||
|
COPY ${SRC_DIR} /go/src/github.com/google/cadvisor
|
||||||
|
|
||||||
|
WORKDIR /go/src/github.com/google/cadvisor
|
||||||
|
|
||||||
|
ARG GOARCH=amd64
|
||||||
|
ENV GOARCH=${GOARCH}
|
||||||
|
RUN make build # release
|
||||||
|
|
||||||
|
FROM ${REPO}/alpine:3.10
|
||||||
|
|
||||||
|
COPY --from=builder /go/src/github.com/google/cadvisor/cadvisor /usr/bin/cadvisor
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
ENTRYPOINT ["/usr/bin/cadvisor", "-logtostderr"]
|
||||||
|
|
||||||
|
# vim: set filetype=dockerfile:
|
85
Makefile
Normal file
85
Makefile
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
PROJECT = cadvisor
|
||||||
|
DOCKER_TAG ?= $(PROJECT)-${USER}
|
||||||
|
VERSION ?= master
|
||||||
|
# Extracted src directory
|
||||||
|
SRC_DIR = src/$(PROJECT)-$(subst v,,$(VERSION))
|
||||||
|
# Multi-arch targets are generated from this
|
||||||
|
TARGETS = cadvisor-amd64 cadvisor-arm cadvisor-arm64
|
||||||
|
|
||||||
|
# Default make target will run tests
|
||||||
|
.DEFAULT_GOAL = build
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test:
|
||||||
|
@echo "no tests"
|
||||||
|
|
||||||
|
# Build all static Minitor binaries
|
||||||
|
.PHONY: all
|
||||||
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
$(SRC_DIR):
|
||||||
|
mkdir -p ./src
|
||||||
|
git clone --depth=1 --branch $(VERSION) https://github.com/google/cadvisor.git $(SRC_DIR)
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
rm -f ./src
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: $(SRC_DIR)
|
||||||
|
./build.sh "$(DOCKER_TAG)" "$(SRC_DIR)"
|
||||||
|
|
||||||
|
## Multi-arch targets
|
||||||
|
$(TARGETS): $(SRC_DIR)
|
||||||
|
GOARCH=$(lastword $(subst -, ,$(@))) \
|
||||||
|
./build.sh "$(DOCKER_TAG)" "$(SRC_DIR)"
|
||||||
|
|
||||||
|
.PHONY: docker-build-env
|
||||||
|
docker-build-env: $(SRC_DIR)
|
||||||
|
docker build -f Dockerfile.build-env . -t $(DOCKER_TAG)-build-env
|
||||||
|
|
||||||
|
.PHONY: build-in-docker
|
||||||
|
build-in-docker: docker-build-env
|
||||||
|
docker run --rm \
|
||||||
|
-v $(shell pwd)/$(SRC_DIR):/go/src/github.com/google/cadvisor \
|
||||||
|
-e GOARCH=amd64 \
|
||||||
|
$(DOCKER_TAG)-build-env \
|
||||||
|
make build \
|
||||||
|
&& cp $(SRC_DIR)/$(PROJECT) ./$(PROJECT)-amd64
|
||||||
|
|
||||||
|
.PHONY: build-in-docker-arm
|
||||||
|
build-in-docker-arm: docker-build-env
|
||||||
|
docker run --rm \
|
||||||
|
-v $(shell pwd)/$(SRC_DIR):/go/src/github.com/google/cadvisor \
|
||||||
|
-e GOARCH=arm \
|
||||||
|
$(DOCKER_TAG)-build-env \
|
||||||
|
make build \
|
||||||
|
&& cp $(SRC_DIR)/$(PROJECT) ./$(PROJECT)-arm
|
||||||
|
|
||||||
|
.PHONY: build-in-docker-arm64
|
||||||
|
build-in-docker-arm64: docker-build-env
|
||||||
|
docker run --rm \
|
||||||
|
-v $(shell pwd)/$(SRC_DIR):/go/src/github.com/google/cadvisor \
|
||||||
|
-e GOARCH=arm64 \
|
||||||
|
$(DOCKER_TAG)-build-env \
|
||||||
|
make build \
|
||||||
|
&& cp $(SRC_DIR)/$(PROJECT) ./$(PROJECT)-arm64
|
||||||
|
|
||||||
|
# Arch specific docker build targets
|
||||||
|
.PHONY: docker-build
|
||||||
|
docker-build: cadvisor-amd64
|
||||||
|
docker build . -t ${DOCKER_TAG}
|
||||||
|
|
||||||
|
.PHONY: docker-build-arm
|
||||||
|
docker-build-arm: cadvisor-arm
|
||||||
|
docker build \
|
||||||
|
--build-arg REPO=arm32v7 \
|
||||||
|
--build-arg GOARCH=arm\
|
||||||
|
. -t ${DOCKER_TAG}-arm
|
||||||
|
|
||||||
|
.PHONY: docker-build-arm64
|
||||||
|
docker-build-arm64: cadvisor-arm64
|
||||||
|
docker build \
|
||||||
|
--build-arg REPO=arm64v8 \
|
||||||
|
--build-arg GOARCH=arm64 \
|
||||||
|
. -t ${DOCKER_TAG}-arm64
|
24
build.sh
Executable file
24
build.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
docker_tag="$1"
|
||||||
|
src_dir="$2"
|
||||||
|
dmsetup="$(which dmsetup)"
|
||||||
|
docker="$(which docker)"
|
||||||
|
export GOARCH="${GOARCH:-amd64}"
|
||||||
|
|
||||||
|
if [ -n "$dmsetup" ]; then
|
||||||
|
# We will build using make
|
||||||
|
make -C "$src_dir" build \
|
||||||
|
&& cp "${src_dir}/cadvisor" "./cadvisor-$GOARCH"
|
||||||
|
elif [ -n "$docker" ]; then
|
||||||
|
# We will build using docker
|
||||||
|
docker run --rm -it \
|
||||||
|
-v "$(pwd)/${src_dir}:/go/src/github.com/google/cadvisor" \
|
||||||
|
-e GOARCH="${GOARCH}" \
|
||||||
|
"${docker_tag}-build-env" \
|
||||||
|
make build \
|
||||||
|
&& cp "${src_dir}/cadvisor" "./cadvisor-$GOARCH"
|
||||||
|
else
|
||||||
|
echo "Either install build dependencies (dmsetup) or Docker"
|
||||||
|
exit 1
|
||||||
|
fi
|
25
manifest.tmpl
Normal file
25
manifest.tmpl
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
image: iamthefij/cadvisor:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||||
|
{{#if build.tags}}
|
||||||
|
tags:
|
||||||
|
{{#each build.tags}}
|
||||||
|
- {{this}}
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
|
manifests:
|
||||||
|
-
|
||||||
|
image: iamthefij/cadvisor:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||||
|
platform:
|
||||||
|
architecture: amd64
|
||||||
|
os: linux
|
||||||
|
-
|
||||||
|
image: iamthefij/cadvisor:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||||
|
platform:
|
||||||
|
architecture: arm64
|
||||||
|
os: linux
|
||||||
|
variant: v8
|
||||||
|
-
|
||||||
|
image: iamthefij/cadvisor:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||||
|
platform:
|
||||||
|
architecture: arm
|
||||||
|
os: linux
|
||||||
|
variant: v7
|
Loading…
Reference in New Issue
Block a user