dockerize
dockerize copied to clipboard
aarch64 support is not correct in the Makefile
Fixed jwilder/dockerize#143 and jwilder/dockerize#154
The aarch64 support is not correct in the Makefile.
https://github.com/jwilder/dockerize/blob/9ce2e80619962abe9ba90619e009d29943446ab3/Makefile#L28
https://github.com/jwilder/dockerize/blob/9ce2e80619962abe9ba90619e009d29943446ab3/Makefile#L39
The aarch64 value in these two lines should be arm64. The aarch64 value is not a valid GOARCH value. Trying to execute make dist
will get an error.
A practical example is making a multi-platform build of a Dockerfile using arm64 and aarch64 values:
All these Dockerfile arguments are automatically filled when using BuildKit. Also, remember to put your user in ${DOCKER_USER}.
FROM alpine
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
ENV TARGETPLATFORM="${TARGETPLATFORM}" \
TARGETOS="${TARGETOS}" \
TARGETARCH="${TARGETARCH}" \
TARGETVARIANT="${TARGETVARIANT}"
RUN echo "\
TARGETPLATFORM='${TARGETPLATFORM}' \
TARGETOS='${TARGETOS}' \
TARGETARCH='${TARGETARCH}' \
TARGETVARIANT='${TARGETVARIANT}'"
ENTRYPOINT echo "($(uname -m)) \
TARGETPLATFORM='${TARGETPLATFORM}' \
TARGETOS='${TARGETOS}' \
TARGETARCH='${TARGETARCH}' \
TARGETVARIANT='${TARGETVARIANT}'"
docker buildx build \
--pull \
--push \
--tag ${DOCKER_USER}/buildx-arm:latest \
--platform linux/arm64 \
--file Dockerfile \
.
The build result is:
[linux/arm64] TARGETPLATFORM='linux/arm64' TARGETOS='linux' TARGETARCH='arm64' TARGETVARIANT=''
Running this image:
docker rmi ${DOCKER_USER}/buildx-arm:latest
docker run --rm --platform linux/arm64 ${DOCKER_USER}/buildx-arm:latest
It will result:
(aarch64) TARGETPLATFORM='linux/arm64' TARGETOS='linux' TARGETARCH='arm64' TARGETVARIANT=''
If you change the buildx parameter --platform linux/arm64
to --platform linux/aarch64
, the build result will be the same:
[linux/arm64] TARGETPLATFORM='linux/arm64' TARGETOS='linux' TARGETARCH='arm64' TARGETVARIANT=''
and the result of running this image will be the same too:
docker rmi ${DOCKER_USER}/buildx-arm:latest
docker run --rm --platform linux/aarch64 ${DOCKER_USER}/buildx-arm:latest
(aarch64) TARGETPLATFORM='linux/arm64' TARGETOS='linux' TARGETARCH='arm64' TARGETVARIANT=''
Even though the results are the same with aarch64 and arm64, GOARCH doesn't recognize the aarch64 value. That is the reason to use arm64 in that two lines of the Makefile.
@sagikazarmark At first, I made this PR with v7 support, but I realized that it could have a backward compatibility issue.
Try creating the Dockerfile I put here in this issue, and build it for armhf, running this command:
docker buildx build \
--pull \
--push \
--tag ${DOCKER_USER}/buildx-arm:latest \
--platform linux/armhf \
--file Dockerfile \
.
Now, try to run the following command:
docker rmi ${DOCKER_USER}/buildx-arm:latest
docker run --rm --platform linux/armhf ${DOCKER_USER}/buildx-arm:latest
It will result:
(armv7l) TARGETPLATFORM='linux/arm/v7' TARGETOS='linux' TARGETARCH='arm' TARGETVARIANT='v7'
As you can see, the docker builds armhf for v7 and not v6, as it is in the source code:
https://github.com/jwilder/dockerize/blob/9ce2e80619962abe9ba90619e009d29943446ab3/Makefile#L27
Thus, how do we solve this by avoiding backward compatibility breaks? It would be another bug (it should be v7 instead of v6 on the 27th line)?
Hi @kaissi - could you provide any kind of guidance on this PR and availability of dockerize on arm64? I am the chairman of the EdgeX Foundry open source project. Our project discovered your tool and have already incorporated it into some of our work. As we run/support both Intel and ARM64 architectures, it would be incredibly helpful if the ARM64 version was made available soon.
Also tagging @sagikazarmark
Hi @jpwhitemn. It's very simple to make these changes.
But, first, you could try using some of the other arm executables:
- https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-linux-armel-v0.6.1.tar.gz
- https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-linux-armhf-v0.6.1.tar.gz
I'm saying that because in my Raspberry Pi 4, these two options work perfectly.
That said, let's go to this PR. While this PR is not merged you can do this by yourself. I'm assuming you are trying to execute the stable version - tag v0.6.1 (the latest right now).
Where you find ${GITHUB_USER}, you must put your Github user, like 'jpwhitemn', for instance.
Just follow these steps:
- Fork this repo;
- Clone your fork and create a branch based on the v0.6.1 tag:
git clone [email protected]:${GITHUB_USER}/dockerize.git
cd dockerize
git checkout -b 0.6.x v0.6.1
- Add these two lines in the Makefile:
- Add the following line in the block of the Makefile command 'dist: deps dist-clean':
mkdir -p dist/linux/arm64 && GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o dist/linux/arm64/dockerize
- Add the following line in the block of the Makefile command 'release: dist':
tar -cvzf dockerize-linux-arm64-$(TAG).tar.gz -C dist/linux/arm64 dockerize
- In the command line, go to the project root folder, commit your change, push back to your fork, and generate a release:
git add --all
git commit -m "Added arm64 support"
git push origin 0.6.x
make release
- All the tar files will be created in your project root folder - including the new dockerize-linux-arm64-v0.6.1.tar.gz tar file;
- You can upload these generated tar files to the tag v0.6.1 of your fork, editing the tag, and uploading the tar files. The URL where you'll do this is https://github.com/${GITHUB_USER}/dockerize/releases/tag/v0.6.1, clicking in 'Edit tag';
After doing these steps you can use your Github URL in your projects.
thanks for this @kaissi . We were able to get things to work, but we were looking for formal acceptance of your PR and to know when this project might actually release again (last was March 2018)? Probably more of a question for @jwilder . We're trying to understand if this project is active or no longer supported.
@jpwhitemn, related to acceptance of this PR only @jwilder can do it. And, if this project is active, see #120 (comment).
Hello any update for this PR ? ping @jwilder
Hello any update for this PR ? ping @jwilder
Hello any update for this PR ? ping @jwilder
@ jwilder, I have also tried with these steps mentioned in the issue
Hi @jpwhitemn. It's very simple to make these changes.
But, first, you could try using some of the other arm executables:
- https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-linux-armel-v0.6.1.tar.gz
- https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-linux-armhf-v0.6.1.tar.gz
I'm saying that because in my Raspberry Pi 4, these two options work perfectly.
That said, let's go to this PR. While this PR is not merged you can do this by yourself. I'm assuming you are trying to execute the stable version - tag v0.6.1 (the latest right now).
Where you find ${GITHUB_USER}, you must put your Github user, like 'jpwhitemn', for instance.
Just follow these steps:
- Fork this repo;
- Clone your fork and create a branch based on the v0.6.1 tag:
git clone [email protected]:${GITHUB_USER}/dockerize.git cd dockerize git checkout -b 0.6.x v0.6.1
- Add these two lines in the Makefile:
- Add the following line in the block of the Makefile command 'dist: deps dist-clean':
mkdir -p dist/linux/arm64 && GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o dist/linux/arm64/dockerize
- Add the following line in the block of the Makefile command 'release: dist':
tar -cvzf dockerize-linux-arm64-$(TAG).tar.gz -C dist/linux/arm64 dockerize
- In the command line, go to the project root folder, commit your change, push back to your fork, and generate a release:
git add --all git commit -m "Added arm64 support" git push origin 0.6.x make release
- All the tar files will be created in your project root folder - including the new dockerize-linux-arm64-v0.6.1.tar.gz tar file;
- You can upload these generated tar files to the tag v0.6.1 of your fork, editing the tag, and uploading the tar files. The URL where you'll do this is https://github.com/${GITHUB_USER}/dockerize/releases/tag/v0.6.1, clicking in 'Edit tag';
After doing these steps you can use your Github URL in your projects.
In the dockerize git repo the binaries are released for armel and armhf. By running the above steps, the arm64 binaries got built successfully. So, could you please release the binaries for arm64 architecture. Please let me know if you need any help in releasing the arm64 binaries.
Could you please merge this PR, it would be really helpful.
Thanks in advance!