Skip to content

Commit

Permalink
build: add multi-stage build support
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Simoncelli <[email protected]>
  • Loading branch information
simon3z committed Oct 4, 2017
1 parent 22dbe4b commit 1f9c3a5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.git
image-inspector
README.md
*.a
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM centos:7
MAINTAINER Federico Simoncelli <[email protected]>

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

Expand Down
8 changes: 8 additions & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM golang:1.7
MAINTAINER Federico Simoncelli <[email protected]>

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
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions hack/build-image.sh
Original file line number Diff line number Diff line change
@@ -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 .

0 comments on commit 1f9c3a5

Please sign in to comment.