ikawaha / kagome

Self-contained Japanese Morphological Analyzer written in pure Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make Dockerfile compatible with ARM architecture

KEINOS opened this issue · comments

[Enhancement]

Happy New Year!

Currently (as of 3641b3f), the Dockerfile creates an image for AMD64 (Intel-compatible) binary with GOARCH=amd64 option.

kagome/Dockerfile

Lines 21 to 32 in 3641b3f

RUN apk --no-cache add git && \
version_app=$(git describe --tag) && \
echo "- Current git tag: ${version_app}" && \
go version && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-a \
-installsuffix cgo \
--ldflags "-w -s -extldflags \"-static\" -X 'main.version=${version_app}'" \
-o /go/bin/kagome \
./cmd/kagome && \
echo '- Running tests ...' && \
/go/bin/kagome version

It would be nice to provide Dockerfile for ARM architecture as well. Such as RaspberryPi 3 (ARMv7) and Raspberry Pi Zero (ARMv6).

Seems that Golang supports ARM architecture and has some success stories on Raspberry Pies.

If I may, as soon as I success to make one, I will PR the Dockerfile. But please keep your expectations low. ;-)

Sounds good!

Finally, I think I came up with a solution to fix this issue.

With this fix, we can provide "ikawaha/kagome:latest" Docker image tag which is compatible with x86_64 (Intel/AMD) and ARMs. Such as ARM v6 (RasPi Zero) and ARM v7 (RasPi 3+). (Maybe compatible with the upcoming ARM Mac as well)

But before any PR, I have a question.

Do you prefer to use GitHub Actions to automate the build and push the images to DockerHub?
or wish to release the images manually?

  1. Automatic
    • PROS: Once the settings are set, only push your commit to "v2" branch and will automatically release the docker images.
    • CONS: You need to set the TOKENs from Docker Hub to the GitHub repo's secret setting for the first time.
  2. Manual
    • PROS: You can control the tags.
    • CONS: You need to enable the experimental feature of Docker.

I suggest the first one, automate, using the GitHub actions.

The thing is that, to make a single Docker image tag,"ikawaha/kagome:latest", which works on all those platforms above is a little complicated.

Because there's a long-lasting bug in Docker which can not detect the architecture, if "arm/v6" and "arm/v7" are mixed in one tag (manifest).

To make it work, we need a temporary workaround. (Change the variant value of "arm6" and "arm7" in "latest" tag's manifest)

I made a GitHub action to do all the things for this. But if you prefer to release the images manually, I will create a shell script to do so.

I prefer automated releases! ╭( ・ㅂ・)و ̑̑

roger ( ̄^ ̄)ゞ

I will PR what I came up with, as soon as I finish some refactoring (cleaning) the workflow.

╭( ・ㅂ・)و ̑̑ Thank you for your great contributions!
We are now able to provide Docker containers for AMD/ARM environments. 🎉

ikawaha_kagome_Tags_-_Docker_Hub

We did it. 10 months to close the issue... finally 😄