Dockerfile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
  2. FROM --platform=linux/amd64 docker.io/golang:1.23.3-bullseye@sha256:bc1b90c2a8eb0ffb62325e02a85d51031ad3afae15b3df4b6a48b7929b00badb AS dev
  3. # libwasmvm.so is not compatible with arm
  4. FROM dev AS build
  5. WORKDIR /app
  6. COPY node/tools tools
  7. RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/go \
  8. cd tools/ && go build -mod=readonly -o /dlv github.com/go-delve/delve/cmd/dlv
  9. COPY node node
  10. COPY sdk sdk
  11. COPY wormchain wormchain
  12. ARG GO_BUILD_ARGS=-race
  13. RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/go \
  14. export CGO_ENABLED=1 && \
  15. cd node && \
  16. go build ${GO_BUILD_ARGS} -gcflags="all=-N -l" --ldflags '-extldflags "-Wl,--allow-multiple-definition" -X "github.com/certusone/wormhole/node/cmd/guardiand.Build=dev"' -mod=readonly -o /guardiand github.com/certusone/wormhole/node && \
  17. go get github.com/CosmWasm/wasmvm@v1.1.1 && \
  18. cp /go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/libwasmvm.x86_64.so /usr/lib/
  19. # Only export the final binary (+ shared objects). This reduces the image size
  20. # from ~1GB to ~150MB.
  21. FROM scratch as export
  22. # guardiand can't (easily) be statically linked due to the C dependencies, so we
  23. # have to copy all the dynamic libraries
  24. COPY --from=build /lib/* /lib/
  25. COPY --from=build /lib64/* /lib64/
  26. COPY --from=build /usr/lib/libwasmvm.x86_64.so /usr/lib/
  27. # Copy the shells as entrypoints, but no utilities are necessary
  28. COPY --from=build /bin/bash /bin/dash /bin/sh /bin/
  29. # finally copy the guardian executable
  30. COPY --from=build /guardiand .
  31. ENTRYPOINT ["/guardiand"]