Skip to content

Commit

Permalink
Cross compile the arm64 image
Browse files Browse the repository at this point in the history
  • Loading branch information
jkozera committed Jul 26, 2024
1 parent 40e25d7 commit 4a386f4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
### Copied from https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-c-plus-plus-service#writing
# Version: 2024.07.25 (modify this line to trigger CI build)
# Version: 2024.07.26 (modify this line to trigger CI build)

FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx

# We chose Alpine to build the image because it has good support for creating
# statically-linked, small programs.
FROM alpine:3.20 AS build
FROM --platform=$BUILDPLATFORM alpine:3.20 AS xbuild
COPY --from=xx / /
ARG TARGETPLATFORM

# Install the typical development tools for C++, and
# the base OS headers and libraries.
Expand Down Expand Up @@ -34,5 +38,21 @@ RUN curl -sSL "https://github.com/Microsoft/vcpkg/archive/2024.07.12.tar.gz" | \
&& for path in triplets/*.cmake triplets/community/*.cmake ; do \
echo 'set(VCPKG_BUILD_TYPE release)' >> $path ; \
done \
&& ./bootstrap-vcpkg.sh -disableMetrics \
&& ./vcpkg install grpc
&& ./bootstrap-vcpkg.sh -disableMetrics

RUN xx-apk add --no-cache musl-dev zlib-dev clang

COPY . /v/source
WORKDIR /v/source

RUN cmake -S/v/source -B/v/binary -GNinja \
-DCMAKE_TOOLCHAIN_FILE=/usr/local/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DCMAKE_BUILD_TYPE=Release \
$(xx-clang --print-cmake-defines)

# Don't include the final binaries in the base image
RUN /v/binary/interaction*

FROM --platform=$BUILDPLATFORM alpine:3.20
COPY --from=xbuild /v/source /v/source
COPY --from=xbuild /v/binary /v/binary
13 changes: 0 additions & 13 deletions cloudfunctions-cc/Dockerfile.base2

This file was deleted.

0 comments on commit 4a386f4

Please sign in to comment.