-
Notifications
You must be signed in to change notification settings - Fork 330
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: Add ARM64 support for Docker builds #4164
base: main
Are you sure you want to change the base?
fix: Add ARM64 support for Docker builds #4164
Conversation
📝 WalkthroughWalkthroughThe pull request introduces a comprehensive modification to the Docker build process, focusing on multi-platform image support. The changes involve updating the GitHub Actions workflow and Dockerfile to enable building and pushing Docker images for both Changes
Sequence DiagramsequenceDiagram
participant GHA as GitHub Actions
participant Docker as Docker Build System
participant Registry as Container Registry
GHA->>Docker: Initiate multi-platform build
Docker->>Docker: Build for amd64
Docker->>Docker: Build for arm64
Docker->>Registry: Push images
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docker/Dockerfile (1)
Line range hint
6-8
: Consider documenting platform support.Since we're adding ARM64 support, it would be helpful to document the supported platforms in the Dockerfile comments.
Add this documentation:
# Separating the builder and runtime image allows the runtime image to be # considerably smaller because it doesn't need to have Golang installed. +# Supported platforms: +# - linux/amd64 +# - linux/arm64
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/reusable_dockerfile_pipeline.yml
(1 hunks)docker/Dockerfile
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/reusable_dockerfile_pipeline.yml
5-5: workflow is sequence node but mapping node is expected
(syntax-check)
5-5: "on" section is missing in workflow
(syntax-check)
5-5: "jobs" section is missing in workflow
(syntax-check)
🔇 Additional comments (4)
.github/workflows/reusable_dockerfile_pipeline.yml (2)
5-13
: LGTM! Multi-platform build configuration looks correct.
The build step is properly configured for multi-architecture support:
- Uses the latest stable version of docker/build-push-action
- Correctly specifies both linux/amd64 and linux/arm64 platforms
- Properly inherits tags and labels from previous steps
🧰 Tools
🪛 actionlint (1.7.4)
5-5: workflow is sequence node but mapping node is expected
(syntax-check)
5-5: "on" section is missing in workflow
(syntax-check)
5-5: "jobs" section is missing in workflow
(syntax-check)
1-3
: Verify the removed AMD64-specific build steps.
Please ensure that any platform-specific environment variables or build arguments from the removed AMD64 build steps are now properly handled in the new multi-platform configuration.
✅ Verification successful
Multi-platform build configuration is properly set up
The verification shows that:
- The old AMD64-specific build steps have been successfully replaced with a proper multi-platform configuration using
docker/build-push-action@v5
- The platforms are correctly configured to build for both
linux/amd64
andlinux/arm64
- No platform-specific build arguments or environment variables are present in the workflow, suggesting a unified build configuration
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining platform-specific configurations
rg -i "amd64|x86_64" .github/workflows/
Length of output: 232
Script:
#!/bin/bash
# Let's check the complete context of the platform configuration
rg -B5 -A5 "platforms:" .github/workflows/reusable_dockerfile_pipeline.yml
# Also check for any build arguments or environment variables that might be platform-specific
rg -i "build-arg|env" .github/workflows/reusable_dockerfile_pipeline.yml
Length of output: 427
docker/Dockerfile (2)
Line range hint 41-77
: LGTM! Runtime stage configuration is solid.
The runtime stage is well-configured for multi-arch support:
- Uses Alpine 3.19 which supports both AMD64 and ARM64
- Follows security best practices
- Properly configured for all required ports
Line range hint 22-40
: Verify ARM64 build compatibility.
The build configuration looks correct for multi-arch support, but let's verify:
- The use of $TARGETPLATFORM is appropriate for cross-compilation
- CGO_ENABLED=0 is correct for cross-platform builds
- The build dependencies should work on ARM64
✅ Verification successful
ARM64 build configuration is correctly set up
The Dockerfile is properly configured for multi-architecture builds:
- Uses
--platform=$TARGETPLATFORM
with golang base image - Correctly sets
CGO_ENABLED=0
which is required for cross-compilation - Properly uses
TARGETOS
andTARGETARCH
build arguments for Go compilation - All build dependencies (gcc, git, linux-headers, make, musl-dev) are architecture-agnostic and available on Alpine Linux for ARM64
- Uses multi-stage build with Alpine Linux base images that support ARM64
The build configuration follows best practices for multi-architecture Docker builds and will work correctly on ARM64 platforms.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if there are any architecture-specific build dependencies or configurations
rg -i "amd64|arm64|x86_64|aarch64" docker/
Length of output: 44
Script:
#!/bin/bash
# Let's check the Dockerfile and related files more thoroughly
cat docker/Dockerfile
# Check if there are any architecture-specific make targets or build flags
fd Makefile --exec cat {}
# Check for any platform-specific build configurations
rg -i "platform|arch|target" docker/
Length of output: 17099
@@ -19,7 +19,7 @@ ARG UPGRADE_HEIGHT_DELAY | |||
# Ignore hadolint rule because hadolint can't parse the variable. | |||
# See https://github.com/hadolint/hadolint/issues/339 | |||
# hadolint ignore=DL3006 | |||
FROM --platform=$BUILDPLATFORM ${BUILDER_IMAGE} AS builder | |||
FROM --platform=$TARGETPLATFORM golang:1.21-alpine AS builder |
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.
Critical: Review base image configuration.
Several issues need attention in the base image configuration:
- The previous version
1.23.1
doesn't exist (Go 1.21 is current stable) - Using non-specific patch version (
1.21
vs1.21.x
) could lead to build inconsistency - Removed explicit registry reference (
docker.io/
) might affect availability
Apply this fix:
-FROM --platform=$TARGETPLATFORM golang:1.21-alpine AS builder
+FROM --platform=$TARGETPLATFORM docker.io/golang:1.21.5-alpine AS builder
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
FROM --platform=$TARGETPLATFORM golang:1.21-alpine AS builder | |
FROM --platform=$TARGETPLATFORM docker.io/golang:1.21.5-alpine AS builder |
Fixes #4128
Changes:
This PR enables Docker builds for ARM64 architecture while maintaining compatibility with AMD64.