Guff666
(Gareth Howell)
September 2, 2024, 3:01pm
1
I’m creating a new local addon to run a Microsoft dotnet
application and I want to be able to deploy the addon to different architectures. There are versions of the dotnet
framework runtime for different architectures; and I can run Microsoft’s installer to ensure the right one gets installed.
When it comes to the application itself though, it’s not so simple. There are versions available for multiple architectures, but I can’t see how to ensure that I download the correct one from the Dockerfile.
What I need is to map ${BUILD_ARCH}
onto a specific filename, but I can’t how to do this.
Any help would be appreciated.
Gareth
koying
(Chris B)
September 3, 2024, 12:53pm
2
Random google search:
Hello, I have a question related to building containers for multi architectures. I am working from a mac the the M1 arm chip. Usually, I write my docker file and use the command docker buildx build --platform linux/arm64,linux/amd64 -t...
Reading time: 1 mins 🕑
Likes: 1 ❤
Are you looking for something else?
Guff666
(Gareth Howell)
September 3, 2024, 3:09pm
3
Thanks, @koying .
That is what I’m looking for but I can’t get it to work. The if statement fails.
I’m using:
RUN \
if [ "$BUILD_ARCH" = "armv7" ]; then \
wget https://www.mkcmsoftware.com/download/FRStackWebApi-rpi-arm64_3_7_3_74.zip && \
unzip FRStackWebApi-rpi-arm64_3_7_3_74.zip; \
elif [ "$BUILD_ARCH" = "amd64" ]; then \
wget https://www.mkcmsoftware.com/download/FRStackWebApi-linux-x64_3_7_3_74.zip && \
unzip FRStackWebApi-linux-64_3_7_3_74.zip; \
fi
koying
(Chris B)
September 3, 2024, 4:41pm
4
“fail” is quite generic, and unlikely to trigger helpful comments, don’t you think?
Maybe try to run the command in a plain shell, to test it.
Guff666
(Gareth Howell)
September 3, 2024, 6:58pm
5
I always endeavour to treat others with a modicum of respect…
koying
(Chris B)
September 3, 2024, 7:52pm
6
It’s not a matter of respect, but of empathy.
We cannot help you if you don’t detail what the failure is.
Anyway, good luck in your endeavor.
Guff666
(Gareth Howell)
September 4, 2024, 7:56am
7
You’re quite right. Fail is pretty unspecific.
I’ll try in a terminal.
Guff666
(Gareth Howell)
September 4, 2024, 9:36am
9
It works OK in a terminal, so I’m wondering if it’s something else in the Dockerfile.
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
ARG BUILD_FROM
FROM $BUILD_FROM
# Execute during the build of the image
ARG TEMPIO_VERSION BUILD_ARCH
RUN \
curl -sSLf -o /usr/bin/tempio \
"https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}"
# install required dependencies
RUN \
apk add \
ca-certificates-bundle \
libgcc \
libssl3 \
libstdc++ \
zlib \
icu-libs
# install dotnet using the Microsoft install script
WORKDIR /temp
RUN \
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && \
bash ./dotnet-install.sh --version latest --runtime aspnetcore --install-dir /usr/local/bin
# Install the appropriate version of FRstackWebApi.dll
RUN mkdir -p /usr/local/frstack
WORKDIR /usr/local/frstack
RUN echo "$BUILD_ARCH"
RUN \
if [ "${BUILD_ARCH}" = "armv7" ]; then \
wget https://www.mkcmsoftware.com/download/FRStackWebApi-rpi-arm64_3_7_3_74.zip && \
unzip FRStackWebApi-rpi-arm64_3_7_3_74.zip; \
elif [ "${BUILD_ARCH}" = "amd64" ]; then \
wget https://www.mkcmsoftware.com/download/FRStackWebApi-linux-x64_3_7_3_74.zip && \
unzip FRStackWebApi-linux-64_3_7_3_74.zip; \
fi
# Copy root filesystem
COPY rootfs /
RUN chmod +x /usr/local/bin/frstackwebapi
This is the error that gets thrown:
The command '/bin/ash -o pipefail -c if [ "${BUILD_ARCH}" = "armv7" ]; then wget https://www.mkcmsoftware.com/download/FRStackWebApi-rpi-arm64_3_7_3_74.zip && unzip FRStackWebApi-rpi-arm64_3_7_3_74.zip;
elif [ "${BUILD_ARCH}" = "amd64" ]; then
wget https://www.mkcmsoftware.com/download/FRStackWebApi-linux-x64_3_7_3_74.zip
&& unzip FRStackWebApi-linux-64_3_7_3_74.zip; fi' returned a non-zero code: 1
(I’ve added newlines as it’s just a single long line)
Guff666
(Gareth Howell)
September 4, 2024, 9:56am
10
OK, I found it.
Simple typo in one of the commands in the if
loop.
Sorry for the bad temper
1 Like