Skip to content
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

Added Support for Dockerized Apple Silicon Installations - PR 311 Fix #314

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MrKovar
Copy link

@MrKovar MrKovar commented Jul 10, 2024

Fix for issue 295: #295

When running the Dockerfile on Apple Silicon the container will crash with a "segmentation fault" caused by the elm binary not being compatible with the arm64 architecture. This updates the Dockerfile to use a new command --build-arg PLATFORM=<arm64/amd64> amd64 by default in the build instructions to build a container specifically for your platform.

Summary by CodeRabbit

  • New Features

    • Introduced support for different architectures in the Docker setup, enhancing flexibility for building and running applications.
    • Added specific instructions for Apple Silicon users in the installation documentation to improve compatibility.
  • Bug Fixes

    • Restructured Dockerfile to ensure correct application file paths and ownership settings for better performance and compatibility.
  • Documentation

    • Updated INSTALL.md to include commands specific to Apple Silicon architecture, improving usability for a wider audience.
  • Chores

    • Modified docker-compose.yml to utilize dynamic platform specifications, making the configuration more adaptable across environments.

Copy link

coderabbitai bot commented Jul 10, 2024

Walkthrough

The changes include the addition of a PLATFORM variable for architecture specification in the .env.example, updates to the Dockerfile to support multi-architecture builds, and enhancements to the docker-compose.yml for dynamic platform settings. The INSTALL.md was also updated to cater specifically to Apple Silicon users. These modifications collectively improve the flexibility and usability of the application across different environments and hardware architectures.

Changes

Files Change Summary
.env.example New environment variable PLATFORM=amd64 added.
Dockerfile Introduced ELM_VERSION and PLATFORM arguments, restructured for multi-architecture (builder_amd64, builder_arm64) support, updated Node.js installation using NVM, adjusted COPY commands and directory permissions.
INSTALL.md Added instructions for Apple Silicon/Arm64 users for running the Azimutt application in Docker.
docker-compose.yml Changed platform from hardcoded linux/amd64 to dynamic reference linux/$PLATFORM and added args section for build arguments.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Docker as Docker Environment
    participant App as Application
    User->>Docker: Run Docker with `--platform` flag
    Docker->>Docker: Build image using specified PLATFORM
    Docker->>App: Deploy application with correct architecture
Loading

🐇 "In the meadow where bunnies play,
A change in code brightens the day.
Platforms now dance, no need to fear,
With Elm and Node, the build is clear!
So hop along, let the builds take flight,
For every architecture, we'll code with delight!" 🐇✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated

FROM --platform=linux/${PLATFORM} ${BUILDER_IMAGE} as builder_arm64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand the tricks with builder_amd64 and builder_arm64 😅

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't very intuitive to make the sure that the platform uses the correct elm binary so I did some research and found that the best way to do it was to use separate build steps, 1 for each platform, and the only use that specific image for the given platform. It took a while to stumble upon this article that helped me create this.

For example, if we use "PLATFORM=amd64", then the builder image will use builder_amd64 since builder is aliasing builder_${PLATFORM}. builder_amd64 will run the single line below it, downloading the elm binary from the official github as opposed to pulling it from the custom image that I created.

So it creates 2 possible images that we would use as builder, then uses the one that matches the platform.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loicknuchel I am actually unsure of the performance this may have on amd64 builds since it may still try to run the COPY under builder_arm64. I'll run a check on this tomorrow, and if its significantly slower, I may just have it download the binary instead of pulling it from the image.

I didn't go that way initially since I don't love the idea of pulling a raw binary from a non-official repo, but we could do a SHA check and make sure it matches the one generated by that dockerfile I created.

Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
@MrKovar
Copy link
Author

MrKovar commented Aug 20, 2024

Thanks for the reviews @SamirPS @loicknuchel ! I'll address them this evening and make things that are hard-coded easier to understand / made into a variable where necessary.

@SamirPS
Copy link

SamirPS commented Aug 21, 2024

Thank @MrKovar

…ose.yml to use environment variables for Platform variable. Added Platform variable to .env.example.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bd1433d and b9fad79.

Files selected for processing (4)
  • .env.example (1 hunks)
  • Dockerfile (5 hunks)
  • INSTALL.md (1 hunks)
  • docker-compose.yml (1 hunks)
Files skipped from review due to trivial changes (1)
  • .env.example
Additional comments not posted (8)
docker-compose.yml (2)

14-14: Dynamic platform specification enhances flexibility.

Replacing the hardcoded platform value with linux/$PLATFORM allows for more adaptable deployments across different architectures.


18-19: Passing PLATFORM as a build argument improves compatibility.

The addition of the args section ensures that the build process can adapt to different architectures by using the specified platform.

Dockerfile (5)

19-19: Default value for ELM_VERSION enhances consistency.

Setting a default value for ELM_VERSION reduces the risk of build errors and ensures consistency across builds.


32-32: Default value for PLATFORM improves usability.

Setting a default value for PLATFORM ensures that the build process can proceed smoothly without requiring explicit specification.


34-34: Platform-specific builder images enhance compatibility.

Incorporating the PLATFORM variable into the BUILDER_IMAGE argument allows for platform-specific builds, improving compatibility with different architectures.


40-46: Platform-specific builder stages improve compatibility.

Introducing builder_amd64 and builder_arm64 ensures that the correct Elm binary is used for each platform, enhancing compatibility and performance.


122-122: Platform-specific final image enhances flexibility.

Using the PLATFORM variable for the final image stage allows for tailored builds, improving flexibility and usability across different architectures.

INSTALL.md (1)

58-66: Tailored instructions for Apple Silicon/Arm64 users enhance usability.

The new section provides specific installation instructions for Apple Silicon/Arm64 users, improving documentation and usability for this user group.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b9fad79 and f32a4ab.

Files selected for processing (1)
  • Dockerfile (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • Dockerfile

@brandondrew
Copy link

I would love to have this available to run on my Mac, in case the love I send your way happens to give any added motivation 💚😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants