[Container-tools] Trick to do a docker "multi-stage-build" using minishift ?

Xavier Coulon xcoulon at redhat.com
Thu Jun 21 11:54:41 UTC 2018


ah sorry, I did not realize that buildah only runs on Linux. But it's great
to hear that you got it working with imagebuilder, though!


On Thu, Jun 21, 2018 at 12:54 PM, Charles Moulliard <cmoullia at redhat.com>
wrote:

> imagebuilder is working. Excellent. Here are the steps I followed to use it
>
> cd $GOPATH/src
> go get -u github.com/openshift/imagebuilder/cmd/imagebuilder
> minishift start
> eval $(minishift docker-env)
> imagebuilder -t gcr.io/kubeships/controller-manager:v1 -f
> Dockerfile.controller .
> --> FROM golang:1.9.4 as builder
> ...
> --> COPY --from=builder /go/src/github.com/cmoulliard/
> my-controller/controller-manager .
> --> ENTRYPOINT ["./controller-manager"]
> --> CMD ["--install-crds=false"]
> --> Committing changes to gcr.io/kubeships/controller-manager:v1 ...
> --> Done
>
> On Thu, Jun 21, 2018 at 12:42 PM, Charles Moulliard <cmoullia at redhat.com>
> wrote:
>
>> Many thanks to share your lights
>>
>> On Thu, Jun 21, 2018 at 11:59 AM, Xavier Coulon <xcoulon at redhat.com>
>> wrote:
>>
>>> 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/projectatom
>>> ic/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)
>>>
>>
>> As I use a MacBook, I don't think that I could use "buildah" as it
>> requires a Linux OS ...
>>
>>>
>>> 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/i
>>> magebuilder - although it's still apparently in beta for now.
>>>
>>> HTH.
>>>
>>>
>>>
>>>
>>> On Thu, Jun 21, 2018 at 11:31 AM, Charles Moulliard <cmoullia at redhat.com
>>> > 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
>>>> Container-tools at redhat.com
>>>> https://www.redhat.com/mailman/listinfo/container-tools
>>>>
>>>>
>>>
>>>
>>> --
>>> Best regards,
>>> /Xavier
>>>
>>
>>
>


-- 
Best regards,
/Xavier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/container-tools/attachments/20180621/6ced8a68/attachment.htm>


More information about the Container-tools mailing list