Dockerfile.release 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. FROM golang:1.8-alpine
  2. RUN apk add --no-cache \
  3. file \
  4. gnupg \
  5. libressl
  6. WORKDIR /usr/src/bashbrew
  7. ENV GOPATH /usr/src/bashbrew:/usr/src/bashbrew/vendor
  8. ENV CGO_ENABLED 0
  9. # https://github.com/estesp/manifest-tool/releases
  10. ENV MANIFEST_TOOL_VERSION 0.6.0
  11. # gpg: key 0F386284C03A1162: public key "Philip Estes <[email protected]>" imported
  12. ENV MANIFEST_TOOL_GPG_KEY 27F3EA268A97867EAF0BD05C0F386284C03A1162
  13. COPY go .
  14. RUN set -ex; \
  15. \
  16. export GNUPGHOME="$(mktemp -d)"; \
  17. gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$MANIFEST_TOOL_GPG_KEY"; \
  18. \
  19. mkdir bin; \
  20. for osArch in \
  21. amd64 \
  22. arm32v5 \
  23. arm32v6 \
  24. arm32v7 \
  25. arm64v8 \
  26. darwin-amd64 \
  27. i386 \
  28. ppc64le \
  29. s390x \
  30. windows-amd64 \
  31. ; do \
  32. os="${osArch%%-*}"; \
  33. [ "$os" != "$osArch" ] || os='linux'; \
  34. export GOOS="$os"; \
  35. arch="${osArch#${os}-}"; \
  36. unset GOARM GO386; \
  37. case "$arch" in \
  38. arm32v*) export GOARCH='arm' GOARM="${arch#arm32v}" ;; \
  39. # no GOARM for arm64 (yet?) -- https://github.com/golang/go/blob/1e72bf62183ea21b9affffd4450d44d994393899/src/cmd/internal/objabi/util.go#L40
  40. arm64v*) export GOARCH='arm64' ;; \
  41. i386) export GOARCH='386' ;; \
  42. *) export GOARCH="$arch" ;; \
  43. esac; \
  44. \
  45. [ "$os" = 'windows' ] && ext='.exe' || ext=''; \
  46. \
  47. go build \
  48. -a -v \
  49. -ldflags '-s -w' \
  50. # see https://github.com/golang/go/issues/9737#issuecomment-276817652 (and following comments) -- installsuffix is necessary (for now) to keep ARM
  51. # can remove "$osArch" from "installsuffix" in Go 1.10+ (https://github.com/golang/go/commit/1b53f15ebb00dd158af674df410c7941abb2b933)
  52. -tags netgo -installsuffix "netgo-$osArch" \
  53. -o "bin/bashbrew-$osArch$ext" \
  54. ./src/bashbrew; \
  55. \
  56. case "$GOARCH" in \
  57. # manifest-tool and GOARM aren't friends yet
  58. # ... and estesp is probably a big fat "lololol" on supporting i386 :D
  59. arm|386) continue ;; \
  60. esac; \
  61. wget -O "bin/manifest-tool-$osArch$ext" "https://github.com/estesp/manifest-tool/releases/download/v${MANIFEST_TOOL_VERSION}/manifest-tool-$GOOS-$GOARCH$ext"; \
  62. wget -O "bin/manifest-tool-$osArch$ext.asc" "https://github.com/estesp/manifest-tool/releases/download/v${MANIFEST_TOOL_VERSION}/manifest-tool-$GOOS-$GOARCH$ext.asc"; \
  63. gpg --batch --verify "bin/manifest-tool-$osArch$ext.asc" "bin/manifest-tool-$osArch$ext"; \
  64. done; \
  65. \
  66. rm -rf "$GNUPGHOME"; \
  67. \
  68. ls -l bin; \
  69. file bin/*