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 Jun 22, 2017
1 parent 53c2256 commit f51bd4b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 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
12 changes: 2 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@ FROM centos:7
MAINTAINER Federico Simoncelli <[email protected]>

RUN yum update -y && \
yum install -y golang openscap-scanner && \
yum install -y openscap-scanner && \
yum clean all

WORKDIR /var/lib/image-inspector

COPY . /go/src/github.com/openshift/image-inspector

RUN GOBIN=/usr/bin \
GOPATH=/go \
CGO_ENABLED=0 \
go install -a -installsuffix cgo /go/src/github.com/openshift/image-inspector/cmd/image-inspector.go && \
mkdir -p /var/lib/image-inspector
COPY image-inspector /usr/bin/image-inspector

EXPOSE 8080

WORKDIR /var/lib/image-inspector

ENTRYPOINT ["/usr/bin/image-inspector"]
8 changes: 8 additions & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM openshift/origin-release: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:
./build-image.sh
.PHONY: image

# Remove all build artifacts.
#
# Example:
Expand Down
18 changes: 18 additions & 0 deletions build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
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 f51bd4b

Please sign in to comment.