-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix & improve docker multi platform builds #176
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,11 +1,7 @@ | ||||||||
# Use ARGs to define default build-time variables for TensorFlow version and target platform | ||||||||
ARG TENSORFLOW_VERSION=v2.14.0 | ||||||||
|
||||||||
FROM golang:1.22.3-bookworm as buildenv | ||||||||
|
||||||||
# Pass in ARGs after FROM to use them in build stage | ||||||||
ARG TENSORFLOW_VERSION | ||||||||
ARG TARGETPLATFORM | ||||||||
FROM --platform=$BUILDPLATFORM golang:1.22.3-bookworm as buildenv | ||||||||
|
||||||||
# Install zip utility along with other dependencies | ||||||||
RUN apt-get update && apt-get install -y \ | ||||||||
|
@@ -15,6 +11,18 @@ RUN apt-get update && apt-get install -y \ | |||||||
zip \ | ||||||||
&& rm -rf /var/lib/apt/lists/* | ||||||||
|
||||||||
WORKDIR /root/src | ||||||||
|
||||||||
ARG TENSORFLOW_VERSION | ||||||||
|
||||||||
# Download TensorFlow headers | ||||||||
RUN git clone --branch ${TENSORFLOW_VERSION} --filter=blob:none --depth 1 --no-checkout https://github.com/tensorflow/tensorflow.git \ | ||||||||
&& git -C tensorflow config core.sparseCheckout true \ | ||||||||
&& echo "**/*.h" >> tensorflow/.git/info/sparse-checkout \ | ||||||||
&& git -C tensorflow checkout | ||||||||
|
||||||||
ARG TARGETPLATFORM | ||||||||
|
||||||||
# Determine PLATFORM based on TARGETPLATFORM | ||||||||
RUN PLATFORM='unknown'; \ | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set the + SHELL ["/bin/bash", "-o", "pipefail"]
RUN curl -L ...
|
||||||||
case "${TARGETPLATFORM}" in \ | ||||||||
|
@@ -28,18 +36,11 @@ RUN PLATFORM='unknown'; \ | |||||||
tar -C "/usr/local/lib" -xz \ | ||||||||
&& ldconfig | ||||||||
|
||||||||
WORKDIR /root/src | ||||||||
|
||||||||
# Download TensorFlow headers | ||||||||
RUN git clone --branch ${TENSORFLOW_VERSION} --filter=blob:none --depth 1 --no-checkout https://github.com/tensorflow/tensorflow.git \ | ||||||||
&& git -C tensorflow config core.sparseCheckout true \ | ||||||||
&& echo "**/*.h" >> tensorflow/.git/info/sparse-checkout \ | ||||||||
&& git -C tensorflow checkout | ||||||||
|
||||||||
FROM buildenv as build | ||||||||
FROM --platform=$BUILDPLATFORM buildenv as build | ||||||||
|
||||||||
# Compile BirdNET-Go | ||||||||
COPY . BirdNET-Go | ||||||||
ARG TARGETPLATFORM | ||||||||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use - RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build cd BirdNET-Go && make TARGETPLATFORM=${TARGETPLATFORM}
+ WORKDIR /BirdNET-Go
+ RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build make TARGETPLATFORM=${TARGETPLATFORM} Committable suggestion
Suggested change
|
||||||||
--mount=type=cache,target=/root/.cache/go-build \ | ||||||||
cd BirdNET-Go && make TARGETPLATFORM=${TARGETPLATFORM} | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
--no-install-recommends
withapt-get install
to avoid installing unnecessary packages.Committable suggestion
Pin versions of packages in
apt-get install
to ensure consistent builds.Committable suggestion