lncm / invoicer

Invoice generating service that lives on top of lnd.
https://hub.docker.com/r/lncm/invoicer
MIT License
8 stars 3 forks source link

Different take on Go env setup #50

Closed meeDamian closed 4 years ago

meeDamian commented 4 years ago

This change is Reviewable

meeDamian commented 4 years ago

Yes. It's quite unfortunate how it's currently impossible to permute the value of ${ARCH} using syntax avail in ENV and ARG only, to match all formats necessary :/.

I just remembered another reason why I used a script modifying Dockerfile instead of using FROM ${ARCH}/alpine:3.11 notation… In the current setup the only thing possible to build w/o passing extra params is a native amd64 image.

Due to ARG ARCH=amd64, even if you build the image on arm32v7, if no params are passed the final stage will be just broken (arm32v7 binaries copied to amd64/alpine:3.11 AS final stage).

I think that one can be fixed using default ARGs, but I still need to look into it.

meeDamian commented 4 years ago

Ok, kill me 😊

lukechilds commented 4 years ago

What's wrong?

meeDamian commented 4 years ago

Ok, I actually found a solution to that! 🤯

FROM ${ARCH:+${ARCH}/}alpine:3.11 AS final

If ARCH is set, use it, but append / to it.

If not, leave it empty.

meeDamian commented 4 years ago

Although I'm running build on arm now, just to make sure…


I guess if all native builds work with a simple:

docker build .

And only cross-compilation requires passing sth extra ex:

docker build --build="ARCH=arm32v7" --build-arg="GOARCH=arm" --build-arg="GOARM=7" .

Then it's not that terrible 🤷🏻‍♂️. Sure, getting rid on the GO* ones would be great, and can perhaps be done somehow later (ex. when FROM --platform= works).

meeDamian commented 4 years ago

Although I'm running build on arm now, just to make sure…

And it didn't work… Gotta investigate, but now laptop is @ 🔋 6%, and no power plug in sight :( .

meeDamian commented 4 years ago

Ok, I think I'm finally quite happy with it ^^.