Closed skanehira closed 1 year ago
okteto build
すると独自のbuild serviceを使っている
BUILDKIT_HOST
で指定できるみたいだけど、docker desktop の場合は domain socket なのでそのまま使えなさそうmoby/buildkit:latest
というのがあるらしい。これを使えば行けそう?moby/buildkitでtcpを立てて、BUILDKIT_HOST
で指定してみたがBuilding 'infra/Dockerfile' in tcp://buildkit.cloud.okteto.net:443...
と出ていて、どうやら接続先が変わっていないみたいで、だめっぽい
$ docker run --name buildkit --privileged -p 1234:1234 moby/buildkit:latest --addr tcp://0.0.0.0:1234
time="2023-05-14T12:08:03Z" level=info msg="auto snapshotter: using overlayfs"
time="2023-05-14T12:08:03Z" level=warning msg="using host network as the default"
time="2023-05-14T12:08:03Z" level=info msg="found worker \"3kz3ql6gsotc2tlxl9bvbucn9\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:29fdebefa7c9 org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]"
time="2023-05-14T12:08:03Z" level=warning msg="skipping containerd worker, as \"/run/containerd/containerd.sock\" does not exist"
time="2023-05-14T12:08:03Z" level=info msg="found 1 workers, default=\"3kz3ql6gsotc2tlxl9bvbucn9\""
time="2023-05-14T12:08:03Z" level=warning msg="currently, only the default worker can be used."
time="2023-05-14T12:08:03Z" level=warning msg="TLS is not enabled for tcp://0.0.0.0:1234. enabling mutual TLS authentication is highly recommended"
time="2023-05-14T12:08:03Z" level=info msg="running server on [::]:1234"
$ export BUILDKIT_HOST=tcp://localhost:1234
$ okteto build --platform=linux/amd64 -t okteto.dev/tabi_plan:latest -f infra/Dockerfile .
i Building 'infra/Dockerfile' in tcp://buildkit.cloud.okteto.net:443...
一旦お手上げなのでコミュニティに質問を投げてみた https://community.okteto.com/t/okteto-build-was-failed-when-i-using-multi-stage-build/817
試しにもう一度やってみたら動いた 原因不明だがひとまず問題ないことは確認できたのでClose
$ make image-build
okteto build --platform=linux/amd64 -t okteto.dev/tabiplan:latest -f infra/Dockerfile
i Building 'infra/Dockerfile' in tcp://buildkit.cloud.okteto.net:443...
[+] Building 42.1s (11/13)
[+] Building 177.5s (14/14) FINISHED
=> [internal] load build definition from buildkit-4117823002 0.6s
=> => transferring dockerfile: 639B 0.5s
=> [internal] load .dockerignore 0.6s
=> => transferring context: 131B 0.5s
=> resolve image config for docker.io/docker/dockerfile:1 0.6s
=> CACHED docker-image://docker.io/docker/dockerfile:1@sha256:39b85bbfa7536a5feceb7372 0.0s
=> => resolve docker.io/docker/dockerfile:1@sha256:39b85bbfa7536a5feceb7372a0817649ecb 0.0s
=> [internal] load metadata for gcr.io/distroless/cc:latest 0.1s
=> [internal] load metadata for docker.io/library/rust:1.69 0.4s
=> [builder 1/4] FROM docker.io/library/rust:1.69@sha256:ee5de9877e3df1180a2a95193ea95 0.0s
=> => resolve docker.io/library/rust:1.69@sha256:ee5de9877e3df1180a2a95193ea954afcaac9 0.0s
=> CACHED [stage-1 1/2] FROM gcr.io/distroless/cc:latest@sha256:9b8e0854865dcaf49470b4 0.0s
=> => resolve gcr.io/distroless/cc:latest@sha256:9b8e0854865dcaf49470b4ec305df45957020 0.0s
=> [internal] load build context 0.8s
=> => transferring context: 36.68kB 0.7s
=> CACHED [builder 2/4] WORKDIR /app 0.0s
=> [builder 3/4] COPY . . 0.1s
=> [builder 4/4] RUN --mount=type=cache,target=/usr/local/cargo/registry --mount 166.6s
=> [stage-1 2/2] COPY --from=builder /tabi_plan /tabi_plan 0.2s
=> exporting to image 5.2s
=> => exporting layers 0.2s
=> => exporting manifest sha256:cb9ea8e15d51522fe2c1e896245b5147b3ea7693757a6fc3dd7804 0.0s
=> => exporting config sha256:f9ba40cfdf847fcf7e81ccb21859efd711a73f372c4c35512ef3935f 0.0s
=> => pushing layers 3.7s
=> => pushing manifest for registry.cloud.okteto.net/skanehira/tabiplan:latest@sha256: 1.3s
✓ Image 'registry.cloud.okteto.net/skanehira/tabiplan:latest' successfully pushed
概要
Okteto で multi stage build しようとすると次のエラーになる
現状、multi stage build ができないので、 rust:1.69 のイメージをそのまま使っている rust:1.69 のイメージ自体が1.5GBくらいあるので、可能な限り小さくしたい 上記の原因について調査する