capnspacehook / whalewall

Automate management of firewall rules for Docker containers
BSD 3-Clause "New" or "Revised" License
244 stars 4 forks source link

Request for ARM64 Docker Build Support for WhaleWall #241

Open alexhopeoconnor opened 2 weeks ago

alexhopeoconnor commented 2 weeks ago

Hello! I’m trying to build WhaleWall as a Docker image for an ARM64 environment (Raspberry Pi 4B) but am encountering issues with the build process. Here’s a detailed overview of the steps I've taken and the issues I'm facing:

Steps to Reproduce:

  1. I started with a Dockerfile to build WhaleWall from source for ARM64. I used Go environment variables GOOS=linux, GOARCH=arm64, and CGO_ENABLED=0 to target ARM64 explicitly.
  2. I downloaded the source code for version v0.2.3 from the release page.
  3. I then attempted to build the binary using go build -o whalewall ..

Dockerfile:

Here’s the Dockerfile I’ve been using:

# Use a Go base image with the appropriate Go version for building
FROM golang:1.23 AS builder

# Set environment variables to target ARM64 explicitly
ENV GOOS=linux
ENV GOARCH=arm64
ENV CGO_ENABLED=0

# Install wget to download the release source code
RUN apt-get update && apt-get install -y wget

# Set the working directory
WORKDIR /src

# Download the source code for v0.2.3 and extract it
RUN wget https://github.com/capnspacehook/whalewall/archive/refs/tags/v0.2.3.tar.gz \
    && tar -xzf v0.2.3.tar.gz --strip-components=1 \
    && rm v0.2.3.tar.gz

# Print Go environment to confirm GOOS and GOARCH
RUN go env

# Attempt to build WhaleWall and capture any errors
RUN go build -o whalewall . || { echo "Build failed"; exit 1; }

# List the contents of the directory to verify the binary exists
RUN ls -lh whalewall || echo "Binary not found after build"

# Verify the binary architecture to ensure it's ARM64, if it exists
RUN [ -f whalewall ] && file whalewall || echo "Binary verification skipped because it was not found"

# Create a minimal runtime image for the final stage
FROM debian:bullseye-slim

# Copy the compiled binary from the builder stage
COPY --from=builder /src/whalewall /usr/local/bin/whalewall

# Set permissions for the binary
RUN chmod +x /usr/local/bin/whalewall

# Default command
ENTRYPOINT ["/usr/local/bin/whalewall"]

Observed Behavior:

  1. The go build command seems to complete without visible errors in the Docker build logs.
  2. However, when I attempt to run the binary, I get the following error: exec format error, indicating that the binary is not built for ARM64 as expected.
  3. When adding file whalewall to check the binary architecture, I sometimes see "file not found," suggesting the binary might not be created properly.

Expected Behavior:

I expected the binary to be built as an aarch64 executable compatible with ARM64 architecture.

Questions:

  1. Is there an official way or any recommended settings to build WhaleWall for ARM64?
  2. Are there any known issues with ARM64 compatibility, or are specific dependencies required for building on this architecture?
  3. Are there any pre-built ARM64 binaries planned for future releases?

Additional Information:

Thank you for your help and any guidance you can provide for building or running WhaleWall on ARM64!