Hello Charles, I've tried it before and failed too, because minishift/Openshift uses an older version of Docker that does not support multi-stage builds:
```` $ eval $(minishift docker-env) $ docker version Client: Version: 18.03.1-ce API version: 1.24 (downgraded from 1.37) Go version: go1.9.5 Git commit: 9ee9f40 Built: Thu Apr 26 07:13:02 2018 OS/Arch: darwin/amd64 Experimental: false Orchestrator: swarm Server: Engine: Version: *1.12.6* API version: 1.24 (minimum version ) Go version: go1.6.4 Git commit: 78d1802 Built: Wed Jan 11 00:23:16 2017 OS/Arch: linux/amd64 Experimental: false ```` I have not tried it yet, but maybe https://github.com/projectatomic/buildah could help since it supports multi-stage builds since V1.0 ( https://github.com/projectatomic/buildah/releases/tag/V1.0 / https://github.com/projectatomic/buildah/pull/495). So you may be able to build and push with Buildah without having to use the Docker daemon running on OpenShift (again, this is just assumptions, it needs to be verified) Also, I found this PR (https://github.com/openshift/imagebuilder/pull/59), so you may want to give a try to https://github.com/openshift/imagebuilder - although it's still apparently in beta for now. HTH. On Thu, Jun 21, 2018 at 11:31 AM, Charles Moulliard <[email protected]> wrote: > Hi > > Is there a trick to be able to do a multi stages build using docker 17.x > running in minishift [1] ? > > E.g. Dockerfile to be processed > > FROM golang:1.9.4 as builder > .. > # Build and test the API code > RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o > controller-manager ./cmd/controller-manager/main.go > RUN go test ./pkg/... ./cmd/... > > # Copy the controller-manager into a thin image > FROM ubuntu:latest > WORKDIR /root/ > COPY --from=builder /go/src/github.com/cmoulliard/ > my-controller/controller-manager . > > Docker reports this error : > > docker build . -f Dockerfile.controller -t gcr.io/kubeships/controller- > manager:v1 > Sending build context to Docker daemon 246MB > Step 1/23 : FROM golang:1.9.4 as builder > Error parsing reference: "golang:1.9.4 as builder" is not a valid > repository/tag: invalid reference format > > [1] https://docs.docker.com/develop/develop-images/multistage-build/ > > Regards > > Charles > > _______________________________________________ > Container-tools mailing list > [email protected] > https://www.redhat.com/mailman/listinfo/container-tools > > -- Best regards, /Xavier
_______________________________________________ Container-tools mailing list [email protected] https://www.redhat.com/mailman/listinfo/container-tools
