|
1 |
| -FROM scratch |
| 1 | +# This Dockerfile tests the hack/Makefile output against git2go. |
| 2 | +ARG BASE_VARIANT=alpine |
| 3 | +ARG GO_VERSION=1.17.6 |
| 4 | +ARG XX_VERSION=1.1.0 |
| 5 | + |
| 6 | +FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx |
| 7 | + |
| 8 | +FROM golang:${GO_VERSION}-${BASE_VARIANT} as gostable |
| 9 | + |
| 10 | +FROM gostable AS go-linux |
| 11 | + |
| 12 | +FROM --platform=$BUILDPLATFORM ${BASE_VARIANT} AS build-deps |
| 13 | + |
| 14 | +RUN apk add --no-cache \ |
| 15 | + bash \ |
| 16 | + curl \ |
| 17 | + build-base \ |
| 18 | + linux-headers \ |
| 19 | + perl \ |
| 20 | + cmake \ |
| 21 | + pkgconfig \ |
| 22 | + gcc \ |
| 23 | + musl-dev \ |
| 24 | + clang \ |
| 25 | + lld |
| 26 | + |
| 27 | +COPY --from=xx / / |
| 28 | + |
| 29 | +ARG TARGETPLATFORM |
| 30 | + |
| 31 | +RUN xx-apk add --no-cache \ |
| 32 | + xx-c-essentials |
| 33 | + |
| 34 | +RUN xx-apk add --no-cache \ |
| 35 | + xx-cxx-essentials |
| 36 | + |
| 37 | +ARG TARGETPLATFORM |
| 38 | +RUN xx-apk add --no-cache \ |
| 39 | + build-base \ |
| 40 | + pkgconfig \ |
| 41 | + gcc \ |
| 42 | + musl-dev \ |
| 43 | + clang \ |
| 44 | + lld \ |
| 45 | + llvm \ |
| 46 | + linux-headers |
| 47 | + |
| 48 | +WORKDIR /build |
| 49 | +COPY hack/static.sh . |
| 50 | + |
| 51 | +ARG TARGETPLATFORM |
| 52 | +ENV CC=xx-clang |
| 53 | +ENV CXX=xx-clang++ |
| 54 | + |
| 55 | +RUN CHOST=$(xx-clang --print-target-triple) \ |
| 56 | + ./static.sh build_libz |
| 57 | + |
| 58 | +RUN CHOST=$(xx-clang --print-target-triple) \ |
| 59 | + ./static.sh build_openssl |
| 60 | + |
| 61 | +RUN export LIBRARY_PATH="/usr/local/$(xx-info triple)/lib:/usr/local/$(xx-info triple)/lib64:${LIBRARY_PATH}" && \ |
| 62 | + export PKG_CONFIG_PATH="/usr/local/$(xx-info triple)/lib/pkgconfig:/usr/local/$(xx-info triple)/lib64/pkgconfig" && \ |
| 63 | + export OPENSSL_ROOT_DIR="/usr/local/$(xx-info triple)" && \ |
| 64 | + export OPENSSL_CRYPTO_LIBRARY="/usr/local/$(xx-info triple)/lib64" && \ |
| 65 | + export OPENSSL_INCLUDE_DIR="/usr/local/$(xx-info triple)/include/openssl" |
| 66 | + |
| 67 | +RUN ./static.sh build_libssh2 |
| 68 | +RUN ./static.sh build_libgit2 |
| 69 | + |
| 70 | + |
| 71 | +FROM go-${TARGETOS} AS build |
| 72 | + |
| 73 | +# Copy cross-compilation tools |
| 74 | +COPY --from=xx / / |
| 75 | +# Copy compiled libraries |
| 76 | +COPY --from=build-deps /usr/local/ /usr/local/ |
2 | 77 |
|
3 | 78 | COPY ./hack/Makefile /Makefile
|
4 | 79 | COPY ./hack/static.sh /static.sh
|
0 commit comments