Skip to content

Commit

Permalink
Actually do something with the result of readelf in case of invalid…
Browse files Browse the repository at this point in the history
… FTL binary

Remove the `cat` of the pihole-FTL binary as it could lead to a very difficult to read logs
Add some more helpful output to the build script

Signed-off-by: Adam Warner <[email protected]>
  • Loading branch information
PromoFaux committed Sep 11, 2024
1 parent 2823d1d commit e938d1a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
21 changes: 18 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ usage() {
}

# Set default values
DOCKER_BUILD_CMD="docker buildx build src/. --tag pihole:local --load --no-cache"
TAG="pihole:local"
DOCKER_BUILD_CMD="docker buildx build src/. --tag ${TAG} --load --no-cache"
FTL_FLAG=false

# Parse command line arguments
Expand Down Expand Up @@ -69,8 +70,9 @@ while [[ $# -gt 0 ]]; do
shift
;;
-t | --tag)
TAG="$2"
DOCKER_BUILD_CMD=${DOCKER_BUILD_CMD/pihole:local/$TAG}
CUSTOM_TAG="$2"
DOCKER_BUILD_CMD=${DOCKER_BUILD_CMD/$TAG/$CUSTOM_TAG}
TAG=$CUSTOM_TAG
shift
shift
;;
Expand All @@ -88,3 +90,16 @@ done
# Execute the docker build command
echo "Executing command: $DOCKER_BUILD_CMD"
eval $DOCKER_BUILD_CMD

# Check exit code of previous command
if [ $? -ne 0 ]; then
echo ""
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!! ERROR: Docker build failed, please review logs above !!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1
else
echo ""
echo "Successfully built Docker image with tag '$TAG'"
docker images $TAG
fi
3 changes: 2 additions & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then FTLARCH=amd64; \
&& echo "Arch: ${TARGETPLATFORM}, FTLARCH: ${FTLARCH}" \
&& curl -sSL "https://ftl.pi-hole.net/${FTL_BRANCH}/pihole-FTL-${FTLARCH}" -o /usr/bin/pihole-FTL \
&& chmod +x /usr/bin/pihole-FTL \
&& readelf -h /usr/bin/pihole-FTL || cat /usr/bin/pihole-FTL
&& readelf -h /usr/bin/pihole-FTL || (echo "Error with downloaded FTL binary" && exit 1)

FROM base AS local-ftl-install
# pihole-FTL must be built from source and copied to the src directory first!
COPY --chmod=0755 pihole-FTL /usr/bin/pihole-FTL
RUN readelf -h /usr/bin/pihole-FTL || (echo "Error with local FTL binary" && exit 1)

# Use the appropriate FTL Install stage based on the FTL_SOURCE build-arg
FROM ${FTL_SOURCE}-ftl-install AS final
Expand Down

0 comments on commit e938d1a

Please sign in to comment.