Merge "Move COPY in Dockerfile and add build script."

This commit is contained in:
Zuul 2020-07-27 15:13:58 +00:00 committed by Gerrit Code Review
commit 85dc2bc789
3 changed files with 17 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
.tox
doc/build
libvirtd_exporter

View File

@ -1,9 +1,9 @@
FROM golang:1.13.5 AS builder
WORKDIR /go/src/app
COPY . .
RUN apt-get update && \
apt-get -y install libvirt-dev && \
apt-get clean all
COPY . .
RUN go build
FROM golang:1.13.5

14
build.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
# Small script to build libvirtd-exporter using docker and export the resulting binary
set -e
docker build -t libvirtd-exporter .
# Start container with result
docker run --entrypoint sh -itd --name libvirtd-exporter libvirtd-exporter
# Extract build atifact to host
docker cp libvirtd-exporter:/libvirtd_exporter .
docker stop libvirtd-exporter
docker rm -f libvirtd-exporter