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

Document Docker build for cross platform images (e.g build on macOS and deploy to amd64) #43

Open
devraj opened this issue Sep 12, 2022 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@devraj
Copy link
Member

devraj commented Sep 12, 2022

At Anomaly we primarily use macOS for development and as Apple moves to Apple Silicon the development environments are moving to arm based CPUs, but most of our deployments are still under amd64 (Intel or AMD based CPUs).

This has caused issues in the past, this should be documented properly and possibly even be made into a Task endpoint

docker build --platform=linux/amd64 -t "anomalyhq/accacia-server:0.2.0" -f Dockerfile .
@devraj devraj changed the title Document Docker build for cross platform Document Docker build for cross platform images (e.g build on macOS and deploy to amd64) Sep 13, 2022
@devraj devraj self-assigned this Oct 13, 2022
@devraj
Copy link
Member Author

devraj commented May 20, 2023

I came across this issue yesterday, I was building fine and then was unable to this week with the no match error messages showing up when it tried to export the image

------
 > exporting to image:
------
ERROR: failed to solve: no match for platform in manifest sha256:30c8...: not found`

I tried almost everything that I could find around the web including what has been mentioned in this ticket.

I am on an Apple Silicon M2 machine and my deployment targer is linux/amd64

Eventually I came across this article Faster Multi-Platform Builds: Dockerfile Cross-Compilation Guide which outlines that buildx is the way to go when support multiple architectures and mentions Graviton2 CPUs on AWS.

I also saw that Moby was updates in v4.19 of Docker desktop

Eventually this is what worked for me.

docker buildx build --platform=linux/amd64,linux/arm64 --push -t "ghcr.io/anomaly/app-server:0.7.0" -f Dockerfile.prod .

Note the --push flag that pushes the built images to ghcr

Hope this helps someone out there struggling with the same issue.

See also M1 mac: docker build allows platform "amd64" but docker run can't find images unless platform is "linux/amd64" where I have left this comment, that issue also references containerd-integration: cannot interact with images that don't have the default platform

@devraj devraj closed this as completed May 20, 2023
@devraj
Copy link
Member Author

devraj commented May 20, 2023

Reopening until this is merged into documentation.

@devraj devraj reopened this May 20, 2023
@devraj devraj added the documentation Improvements or additions to documentation label May 20, 2023
@devraj
Copy link
Member Author

devraj commented Jun 20, 2023

This Stackoverflow post highlights the use of the --entrypoint flag to mount a shell in interactive mode, which overrides the default entrypoint.

docker run -it --entrypoint sh image_name

This was very useful when debugging why the labs server image worked in development using compose but failed to work when I built and published the image to the Github container repository.

devraj added a commit to anomaly/lab-python-mock-server that referenced this issue Jun 20, 2023
the path in docker-compose explicitly mounted /src/lab_mock to /opt/lab_mock
which would have overwritten what would essentially be a bug in the build
step where the files from /src/lab_mock are being copied into /opt/lab_mock/lab_mock
failing the uvicorn command to find the files when the image is built and
pushed to the github repository

we should maintain this image constantly so we can test these simple use cases
this also follows some docker build issues we have had in the past, while
these commands have been documented into tickets
anomaly/lab-python-server#43

we should make them part of the build process and Taskfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant