diff --git a/.dockerignore b/.dockerignore index 4de1721..723254a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ .git -image-inspector README.md *.a diff --git a/Dockerfile b/Dockerfile index f4ea504..41aeb87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ FROM centos:7 MAINTAINER Federico Simoncelli -RUN yum update -y && \ - yum install -y golang openscap-scanner git && \ - yum clean all +RUN yum update -y --setopt=tsflags=nodocs && \ + yum install -y --setopt=tsflags=nodocs golang openscap-scanner git && \ + rm -rf /var/cache/yum COPY . /go/src/github.com/openshift/image-inspector diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..a443fc2 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,8 @@ +FROM golang:1.7 +MAINTAINER Federico Simoncelli + +COPY . /go/src/github.com/openshift/image-inspector + +RUN GOBIN=/usr/bin \ + CGO_ENABLED=0 \ + go install -a -installsuffix cgo /go/src/github.com/openshift/image-inspector/cmd/image-inspector.go diff --git a/Makefile b/Makefile index d56fec4..823be40 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,14 @@ all build: hack/build-go.sh .PHONY: all build +# Build image. +# +# Example: +# make image +image: + hack/build-image.sh +.PHONY: image + # Remove all build artifacts. # # Example: diff --git a/hack/build-image.sh b/hack/build-image.sh new file mode 100755 index 0000000..3bd5e6c --- /dev/null +++ b/hack/build-image.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +IMAGENAME=${IMAGENAME:-docker.io/openshift/image-inspector} +EXTRACTNAME=${EXTRACTNAME:-image-inspector-extract} +BINNAME=image-inspector + +rm -f ${BINNAME} + +echo Building ${IMAGENAME}:build + +docker build --no-cache --pull -t ${IMAGENAME}:build . -f Dockerfile.build + +docker create --name ${EXTRACTNAME} ${IMAGENAME}:build +docker cp ${EXTRACTNAME}:/usr/bin/${BINNAME} ${BINNAME} +docker rm -f ${EXTRACTNAME} + +echo Building ${IMAGENAME}:latest + +docker build --no-cache --pull -t ${IMAGENAME}:latest .