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

aarch64 support is not correct in the Makefile #155

Merged
merged 2 commits into from
May 1, 2023

Conversation

kaissi
Copy link
Contributor

@kaissi kaissi commented Oct 30, 2020

Fixed #143 and #154

The aarch64 support is not correct in the Makefile.

mkdir -p dist/linux/aarch64 && GOOS=linux GOARCH=aarch64 go build -ldflags "$(LDFLAGS)" -o dist/linux/aarch64/dockerize

tar -cvzf dockerize-linux-aarch64-$(TAG).tar.gz -C dist/linux/aarch64 dockerize

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.

@kaissi kaissi changed the title Fixed jwilder/dockerize#143 - aarch64 support is not correct in the Makefile aarch64 support is not correct in the Makefile Nov 13, 2020
Copy link

@sagikazarmark sagikazarmark left a comment

Choose a reason for hiding this comment

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

I guess adding arm v7 support would also make sense (probably in a different PR).

I think something like goreleaser would be great for this project.

@kaissi
Copy link
Contributor Author

kaissi commented Jan 11, 2021

@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:

mkdir -p dist/linux/armhf && GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "$(LDFLAGS)" -o dist/linux/armhf/dockerize

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)?

@jpwhitemn
Copy link

jpwhitemn commented Jan 26, 2021

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

@kaissi
Copy link
Contributor Author

kaissi commented Jan 27, 2021

Hi @jpwhitemn. It's very simple to make these changes.

But, first, you could try using some of the other arm executables:

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:

  1. Fork this repo;
  2. 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
  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

  1. 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
  1. 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;
  2. 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.

@jpwhitemn
Copy link

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.

@kaissi
Copy link
Contributor Author

kaissi commented Jan 27, 2021

@jpwhitemn, related to acceptance of this PR only @jwilder can do it. And, if this project is active, see #120 (comment).

@bourvill
Copy link

Hello any update for this PR ? ping @jwilder

@sanemat
Copy link

sanemat commented Sep 2, 2021

Hello any update for this PR ? ping @jwilder

@LoboMetalurgico
Copy link

Hello any update for this PR ? ping @jwilder

@odidev
Copy link

odidev commented Apr 28, 2023

@ 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:

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:

  1. Fork this repo;
  2. 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
  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

  1. 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
  1. 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;
  2. 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!

@jwilder jwilder merged commit 94c73b1 into jwilder:master May 1, 2023
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.

aarch64 release missing?
8 participants